Skip to content

Commit

Permalink
Tests use ESM again
Browse files Browse the repository at this point in the history
A bit surprising, given that I had so much trouble with decorators and the previous configuration. But now it seems to work well together (ESM + TC39 decorators)

Signed-off-by: Mike Lischke <mike@lischke-online.de>
  • Loading branch information
mike-lischke committed Dec 26, 2023
1 parent e5def56 commit 7b4e61e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"runtimeArgs": [
"--experimental-vm-modules",
"--no-warnings",
"--loader",
"ts-node/esm",
"${workspaceRoot}/node_modules/.bin/jest",
"${file}",
"--no-coverage",
Expand Down
7 changes: 4 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const config: Config = {
"node",
],

//extensionsToTreatAsEsm: [".ts"],
extensionsToTreatAsEsm: [".ts"],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources
// with a single module
Expand All @@ -127,7 +127,7 @@ const config: Config = {
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: "ts-jest",
//preset: "ts-jest/presets/default-esm",

// Run tests from one or more projects
// projects: undefined,
Expand All @@ -152,7 +152,7 @@ const config: Config = {

// A list of paths to directories that Jest should use to search for files in
roots: [
"tests",
"./tests",
],

// Allows you to use a custom runner instead of Jest's default test runner
Expand Down Expand Up @@ -210,6 +210,7 @@ const config: Config = {
transform: {
"^.+\\.ts$": ["ts-jest", {
tsconfig: "./tests/tsconfig.json",
useESM: true,
}],
},

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"prepublishOnly": "npm run build && npm run test",
"hello-world": "ts-node src/runner ./examples/HelloWorld.ts",
"build": "tsc",
"test": "jest --testMatch [ \"**/tests/**/*.spec.ts\" ] --no-coverage --watchAll=false --max-worker=1",
"test-ci": "jest --testMatch [ \"**/tests/**/*.spec.ts\" ] --no-coverage --watchAll=false --silent",
"test-coverage": "jest --testMatch [ \"**/tests/**/*.spec.ts\" ] --coverage --silent",
"test": "jest --testMatch [ \"**/tests/**/*.spec.ts\" ] --no-coverage --watchAll=false --max-worker=10",
"test-ci": "npm run test -- --silent",
"test-coverage": "npm run test -- --coverage --silent",
"lint": "eslint \"./src/**/*.ts\""
}
}
6 changes: 3 additions & 3 deletions tests/java/io/Unicode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { S } from "../../../src/templates.js";
import { runTest } from "../../test-helpers.js";
import { Unicode } from "../../jdk/java/io/Unicode.js";

describe("Unicode Tests", () => {
xit("Base", async () => {
xit("Base", () => {
// For now disabled, as we need a text encoder with more than just UTF-8.
await runTest("tests/jdk/java/io/Unicode.ts", "main", [[S`utf-16le`, S`little`, S`false`]]);
Unicode.main([S`utf-16le`, S`little`, S`false`]);
});

});
6 changes: 3 additions & 3 deletions tests/java/lang/Appendable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { runTest } from "../../test-helpers.js";
import { Basic } from "../../jdk/java/lang/Appendable/Basic.js";

describe("Tests", () => {
it("Basic", async () => {
await runTest("tests/jdk/java/lang/Appendable/Basic.ts", "main");
it("Basic", () => {
Basic.main([]);
});
});
2 changes: 1 addition & 1 deletion tests/java/util/List.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("List Tests", () => {
testNG.run(ListDefaults);
});

describe.only("JDK ListFactories", () => {
describe("JDK ListFactories", () => {
const testNG = new TestNG();
testNG.run(ListFactories);
});
Expand Down
42 changes: 0 additions & 42 deletions tests/test-helpers.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"moduleResolution": "Node16",
"target": "ES2022",
"module": "CommonJS",
"module": "Node16",
"noEmit": true,
"declaration": true,
"sourceMap": true,
Expand Down

0 comments on commit 7b4e61e

Please sign in to comment.