Skip to content

Commit 478eb18

Browse files
committed
refactor: move old unit tests to integ tests to better reflect what they are
1 parent e07c026 commit 478eb18

20 files changed

+3576
-5471
lines changed

.moon/tasks.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ tasks:
7272
deps:
7373
- "build"
7474

75+
test/integ:
76+
command: "jest --passWithNoTests --silent -c jest.config.integ.js"
77+
inputs:
78+
- "@globs(sources)"
79+
- "@globs(tests)"
80+
- "@globs(configs)"
81+
- "tsconfig.json"
82+
- "/tsconfig.json"
83+
- "/tsconfig.base.json"
84+
deps:
85+
- "build"
86+
7587
clean:
7688
command: "rm -rf"
7789
args:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-undef
2+
module.exports = {
3+
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
4+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
// eslint-disable-next-line no-undef
3+
module.exports = {
4+
preset: "ts-jest",
5+
testEnvironment: "node",
6+
transform: {
7+
"^.+\\.tsx?$": [
8+
"ts-jest",
9+
{
10+
tsconfig: "tsconfig.test.json",
11+
},
12+
],
13+
},
14+
testPathIgnorePatterns: [
15+
"/node_modules/",
16+
"<rootDir>/src/",
17+
"<rootDir>/.rollup.cache/",
18+
],
19+
};
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
const esmModules = [
2+
"find-up",
3+
"locate-path",
4+
"p-locate",
5+
"p-limit",
6+
"yocto-queue",
7+
"path-exists",
8+
"stack-trace",
9+
];
10+
111
/** @type {import('ts-jest').JestConfigWithTsJest} */
212
module.exports = {
313
preset: "ts-jest",
414
testEnvironment: "node",
515
transform: {
6-
"^.+\\.tsx?$": [
7-
"ts-jest",
8-
{
9-
tsconfig: "tsconfig.test.json",
10-
},
11-
],
16+
"^.+\\.tsx?$": ["ts-jest"],
17+
// transform js with babel-jest
18+
"^.+\\.js$": "babel-jest",
1219
},
20+
testPathIgnorePatterns: [
21+
"/node_modules/",
22+
"<rootDir>/tests/",
23+
"<rootDir>/.rollup.cache/",
24+
],
25+
transformIgnorePatterns: [
26+
`node_modules/(?!(?:.pnpm/)?(${esmModules.join("|")}))`,
27+
],
1328
};

packages/benchmark.js-plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"homepage": "https://codspeed.io",
2020
"license": "Apache-2.0",
2121
"devDependencies": {
22+
"@babel/preset-env": "^7.22.5",
2223
"@types/benchmark": "^2.1.2",
2324
"@types/find-up": "^4.0.0",
2425
"@types/stack-trace": "^0.0.30",

packages/benchmark.js-plugin/rollup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig([
1414
sourcemap: true,
1515
},
1616
],
17-
plugins: declarationsPlugin,
17+
plugins: declarationsPlugin({ compilerOptions: { composite: false } }),
1818
},
1919
{
2020
input: entrypoint,

packages/benchmark.js-plugin/tests/__snapshots__/unit.test.ts.snap renamed to packages/benchmark.js-plugin/tests/__snapshots__/index.integ.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports[`Benchmark check console output(instrumented=true) 1`] = `
1515
{
1616
"log": [
1717
[
18-
" ✔ Measured packages/benchmark.js-plugin/tests/unit.test.ts::RegExpSingle",
18+
" ✔ Measured packages/benchmark.js-plugin/tests/index.integ.test.ts::RegExpSingle",
1919
],
2020
[
2121
"[CodSpeed] Done running 1 benches.",
@@ -40,10 +40,10 @@ exports[`Benchmark.Suite check console output(instrumented=true) 1`] = `
4040
{
4141
"log": [
4242
[
43-
" ✔ Measured packages/benchmark.js-plugin/tests/unit.test.ts::thesuite::RegExp",
43+
" ✔ Measured packages/benchmark.js-plugin/tests/index.integ.test.ts::thesuite::RegExp",
4444
],
4545
[
46-
" ✔ Measured packages/benchmark.js-plugin/tests/unit.test.ts::thesuite::unknown_1",
46+
" ✔ Measured packages/benchmark.js-plugin/tests/index.integ.test.ts::thesuite::unknown_1",
4747
],
4848
[
4949
"[CodSpeed] Done running 2 benches.",

packages/benchmark.js-plugin/tests/unit.test.ts renamed to packages/benchmark.js-plugin/tests/index.integ.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("Benchmark", () => {
5656
expect(onComplete).toHaveBeenCalled();
5757
expect(mockCore.startInstrumentation).toHaveBeenCalled();
5858
expect(mockCore.stopInstrumentation).toHaveBeenCalledWith(
59-
"packages/benchmark.js-plugin/tests/unit.test.ts::RegExpSingle"
59+
"packages/benchmark.js-plugin/tests/index.integ.test.ts::RegExpSingle"
6060
);
6161
});
6262
it("check error handling", async () => {
@@ -139,7 +139,7 @@ describe("Benchmark.Suite", () => {
139139
await suite.run({ maxTime: 0.1, initCount: 1 });
140140
expect(mockCore.startInstrumentation).toHaveBeenCalled();
141141
expect(mockCore.stopInstrumentation).toHaveBeenCalledWith(
142-
"packages/benchmark.js-plugin/tests/unit.test.ts::RegExp"
142+
"packages/benchmark.js-plugin/tests/index.integ.test.ts::RegExp"
143143
);
144144
});
145145
it("check suite name is in the uri", async () => {
@@ -157,10 +157,10 @@ describe("Benchmark.Suite", () => {
157157
}, benchOptions)
158158
.run();
159159
expect(mockCore.stopInstrumentation).toHaveBeenCalledWith(
160-
"packages/benchmark.js-plugin/tests/unit.test.ts::thesuite::RegExp"
160+
"packages/benchmark.js-plugin/tests/index.integ.test.ts::thesuite::RegExp"
161161
);
162162
expect(mockCore.stopInstrumentation).toHaveBeenCalledWith(
163-
"packages/benchmark.js-plugin/tests/unit.test.ts::thesuite::unknown_1"
163+
"packages/benchmark.js-plugin/tests/index.integ.test.ts::thesuite::unknown_1"
164164
);
165165
});
166166
it("check error handling", async () => {

packages/benchmark.js-plugin/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"outDir": "dist",
55
"rootDir": "src",
6+
"types": ["jest", "node"],
67
"typeRoots": ["node_modules/@types", "../../node_modules/@types"]
78
},
89
"include": ["src/**/*.ts"]

packages/core/jest.config.integ.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
// eslint-disable-next-line no-undef
3+
module.exports = {
4+
preset: "ts-jest",
5+
testEnvironment: "node",
6+
transform: {
7+
"^.+\\.tsx?$": [
8+
"ts-jest",
9+
{
10+
tsconfig: "tsconfig.test.json",
11+
},
12+
],
13+
},
14+
testPathIgnorePatterns: [
15+
"/node_modules/",
16+
"<rootDir>/src/",
17+
"<rootDir>/.rollup.cache/",
18+
],
19+
};

0 commit comments

Comments
 (0)