Skip to content

Commit a234950

Browse files
authored
test: migrate to node test runner (#978)
1 parent c23c793 commit a234950

File tree

7 files changed

+95
-681
lines changed

7 files changed

+95
-681
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"generate:tests": "tsx scripts/generateNewClientTests",
4040
"lint": "biome lint --write",
4141
"release": "tsx scripts/testUpdatedIdentifiers && yarn build && changeset publish",
42-
"test": "vitest"
42+
"test": "node --import tsx --test src/**/*.spec.ts"
4343
},
4444
"dependencies": {
4545
"jscodeshift": "17.1.1"
@@ -52,8 +52,7 @@
5252
"@types/node": "^16.18.101",
5353
"aws-sdk": "2.1692.0",
5454
"tsx": "^4.7.1",
55-
"typescript": "~5.7.2",
56-
"vitest": "^3.0.3"
55+
"typescript": "~5.7.2"
5756
},
5857
"engines": {
5958
"node": ">=16.0.0"
Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
import { describe, expect, it } from "vitest";
1+
import { strictEqual, throws } from "node:assert";
2+
import { describe, it } from "node:test";
23

34
import { CLIENT_NAMES_MAP } from "../config";
45
import { getV3ClientName } from "./getV3ClientName";
56

67
describe(getV3ClientName.name, () => {
7-
it.each(Object.entries(CLIENT_NAMES_MAP))("getV3ClientName('%s') === '%s'", (input, output) => {
8-
expect(getV3ClientName(input)).toBe(output);
9-
});
8+
for (const [input, output] of Object.entries(CLIENT_NAMES_MAP)) {
9+
it(`getV3ClientName('${input}') === '${output}'`, () => {
10+
strictEqual(getV3ClientName(input), output);
11+
});
12+
}
1013

11-
it.each(["ImportExport", "MobileAnalytics", "SimpleDB"])(
12-
"throws for deprecated client '%s'",
13-
(deprecatedClient) => {
14-
expect(() => {
15-
getV3ClientName(deprecatedClient);
16-
}).toThrow(new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`));
17-
}
18-
);
14+
for (const deprecatedClient of ["ImportExport", "MobileAnalytics", "SimpleDB"]) {
15+
it(`throws for deprecated client '${deprecatedClient}'`, () => {
16+
throws(
17+
() => {
18+
getV3ClientName(deprecatedClient);
19+
},
20+
new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`)
21+
);
22+
});
23+
}
1924

20-
it.each(["UNDEFINED", "NULL", "UNKNOWN"])("throws for unknown client '%s'", (unknownClient) => {
21-
expect(() => {
22-
getV3ClientName(unknownClient);
23-
}).toThrow(new Error(`Client '${unknownClient}' is either deprecated or newly added.`));
24-
});
25+
for (const unknownClient of ["UNDEFINED", "NULL", "UNKNOWN"]) {
26+
it(`throws for unknown client '${unknownClient}'`, () => {
27+
throws(
28+
() => {
29+
getV3ClientName(unknownClient);
30+
},
31+
new Error(`Client '${unknownClient}' is either deprecated or newly added.`)
32+
);
33+
});
34+
}
2535
});
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
import { describe, expect, it } from "vitest";
1+
import { strictEqual, throws } from "node:assert";
2+
import { describe, it } from "node:test";
23

34
import { CLIENT_PACKAGE_NAMES_MAP } from "../config";
45
import { getV3ClientPackageName } from "./getV3ClientPackageName";
56

67
describe(getV3ClientPackageName.name, () => {
7-
it.each(Object.entries(CLIENT_PACKAGE_NAMES_MAP))(
8-
"getClientName('%s') === '%s'",
9-
(input, output) => {
10-
expect(getV3ClientPackageName(input)).toBe(`@aws-sdk/${output}`);
11-
}
12-
);
8+
for (const [input, output] of Object.entries(CLIENT_PACKAGE_NAMES_MAP)) {
9+
it("getClientName('%s') === '%s'", () => {
10+
strictEqual(getV3ClientPackageName(input), `@aws-sdk/${output}`);
11+
});
12+
}
1313

14-
it.each(["ImportExport", "MobileAnalytics", "SimpleDB"])(
15-
"throws for deprecated client '%s'",
16-
(deprecatedClient) => {
17-
expect(() => {
18-
getV3ClientPackageName(deprecatedClient);
19-
}).toThrow(new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`));
20-
}
21-
);
14+
for (const deprecatedClient of ["ImportExport", "MobileAnalytics", "SimpleDB"]) {
15+
it("throws for deprecated client '%s'", () => {
16+
throws(
17+
() => {
18+
getV3ClientPackageName(deprecatedClient);
19+
},
20+
new Error(`Client '${deprecatedClient}' is either deprecated or newly added.`)
21+
);
22+
});
23+
}
2224

23-
it.each(["UNDEFINED", "NULL", "UNKNOWN"])("throws for unknown client '%s'", (unknownClient) => {
24-
expect(() => {
25-
getV3ClientPackageName(unknownClient);
26-
}).toThrow(new Error(`Client '${unknownClient}' is either deprecated or newly added.`));
27-
});
25+
for (const unknownClient of ["UNDEFINED", "NULL", "UNKNOWN"]) {
26+
it("throws for unknown client '%s'", () => {
27+
throws(
28+
() => {
29+
getV3ClientPackageName(unknownClient);
30+
},
31+
new Error(`Client '${unknownClient}' is either deprecated or newly added.`)
32+
);
33+
});
34+
}
2835
});

src/transforms/v2-to-v3/transformer.spec.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { strictEqual } from "node:assert";
12
import { readdirSync } from "node:fs";
23
import { readFile } from "node:fs/promises";
34
import { join } from "node:path";
5+
import { describe, it } from "node:test";
46
import jscodeshift from "jscodeshift";
5-
import { describe, expect, it } from "vitest";
67

78
import transform from "./transformer";
89

@@ -34,25 +35,29 @@ describe("v2-to-v3", () => {
3435
return { input, outputCode };
3536
};
3637

37-
describe.each(fixtureSubDirs)("%s", (subDir) => {
38-
const subDirPath = join(fixtureDir, subDir);
39-
it.concurrent.each(getTestFileMetadata(subDirPath))(
40-
"transforms: %s.%s",
41-
async (filePrefix, fileExtension) => {
42-
const { input, outputCode } = await getTestMetadata(subDirPath, filePrefix, fileExtension);
43-
44-
const output = await transform(input, {
45-
j: jscodeshift,
46-
jscodeshift,
47-
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
48-
stats: () => {},
49-
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
50-
report: () => {},
38+
for (const subDir of fixtureSubDirs) {
39+
describe(subDir, () => {
40+
const subDirPath = join(fixtureDir, subDir);
41+
for (const [filePrefix, fileExtension] of getTestFileMetadata(subDirPath)) {
42+
it(`transforms: ${filePrefix}.${fileExtension}`, { concurrency: true }, async () => {
43+
const { input, outputCode } = await getTestMetadata(
44+
subDirPath,
45+
filePrefix,
46+
fileExtension
47+
);
48+
49+
const output = await transform(input, {
50+
j: jscodeshift,
51+
jscodeshift,
52+
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
53+
stats: () => {},
54+
// biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
55+
report: () => {},
56+
});
57+
58+
strictEqual(output.trim(), outputCode.trim());
5159
});
52-
53-
expect(output.trim()).toEqual(outputCode.trim());
54-
},
55-
100000
56-
);
57-
});
60+
}
61+
});
62+
}
5863
});
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { describe, expect, it } from "vitest";
1+
import { strictEqual } from "node:assert";
2+
import { describe, it } from "node:test";
23

34
import { isTypeScriptFile } from "./isTypeScriptFile";
45

56
describe(isTypeScriptFile.name, () => {
6-
it.each([
7+
for (const [output, input] of [
78
[true, "foo.ts"],
89
[true, "foo.tsx"],
910
[false, "foo.js"],
1011
[false, "foo.jsx"],
11-
])("should return %b for %s", (output, input) => {
12-
expect(isTypeScriptFile(input)).toBe(output);
13-
});
12+
] as const) {
13+
it(`should return ${output} for ${input}`, () => {
14+
strictEqual(isTypeScriptFile(input), output);
15+
});
16+
}
1417
});

vitest.config.mjs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)