Skip to content

Commit e48b558

Browse files
committed
Fix Jest execution in worktrees
1 parent 3c02d13 commit e48b558

10 files changed

Lines changed: 57 additions & 50 deletions

File tree

apps/api/jest.config.cjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
const baseConfig = require('../../jest.config.cjs');
2+
13
module.exports = {
2-
testEnvironment: "node",
3-
testMatch: ["<rootDir>/src/*.test.js"],
4-
transform: {},
4+
...baseConfig,
5+
testEnvironment: 'node',
6+
rootDir: '../..',
7+
testMatch: ['**/apps/api/src/*.test.js'],
58
};

apps/cli/jest.config.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
const baseConfig = require('../../jest.config.cjs');
2+
13
module.exports = {
2-
verbose: true,
4+
...baseConfig,
35
testEnvironment: 'node',
4-
transform: {
5-
'^.+\\.js$': 'babel-jest',
6-
},
7-
testMatch: ['<rootDir>/src/tests/**/*.test.js'],
6+
rootDir: '../..',
7+
testMatch: ['**/apps/cli/src/tests/**/*.test.js'],
88
};

apps/cli/src/tests/integration.cli-params.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ test('params --stream and --show-progress true use streaming path for csv/jsonl/
126126
const written = await fs.readFile(outputPath, 'utf8');
127127
expect(written.length).toBeGreaterThan(0);
128128
}
129-
});
129+
}, 20000);
130130

131131
test('param --stream-threshold auto-enables stream mode when threshold reached', () => {
132132
const inputPath = path.join(repoRoot, 'apps', 'cli', 'examples', 'company-literal.txt');

apps/mcp/jest.config.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const baseConfig = require('../../jest.config.cjs');
2+
3+
module.exports = {
4+
...baseConfig,
5+
rootDir: '../..',
6+
testMatch: ['**/apps/mcp/src/*.test.js'],
7+
};

apps/mcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"scripts": {
2121
"build": "node -e \"console.log('mcp: no build step')\"",
2222
"start": "node ./src/index.js",
23-
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --config ../../package.json --testMatch \"<rootDir>/apps/mcp/src/*.test.js\""
23+
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --config ./jest.config.cjs"
2424
},
2525
"dependencies": {
2626
"@anywaydata/core": "workspace:^"

apps/web/src/tests/jest/script-bootstrap.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ describe('script bootstrap', () => {
7979
expect(createDataGridComponentFn).toHaveBeenCalledWith({
8080
root: dom.window.document.getElementById('main-grid-view'),
8181
documentObj: dom.window.document,
82-
services: {
82+
services: expect.objectContaining({
8383
TabulatorCtor: globalThis.Tabulator,
8484
GridExtensionClass: expect.any(Function),
85-
},
85+
getPreviewExportFormats: expect.any(Function),
86+
previewAs: expect.any(Function),
87+
exportAs: expect.any(Function),
88+
}),
8689
});
8790
expect(dom.window.document.getElementById('initial-load')).toBeNull();
8891
});

apps/web/src/tests/jest/script-module-init.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,13 @@ describe('script module initialization', () => {
117117
expect(createDataGridComponent).toHaveBeenCalledWith({
118118
root: global.document.getElementById('main-grid-view'),
119119
documentObj: global.document,
120-
services: {
120+
services: expect.objectContaining({
121121
TabulatorCtor: globalThis.Tabulator,
122122
GridExtensionClass: expect.any(Function),
123-
},
123+
getPreviewExportFormats: expect.any(Function),
124+
previewAs: expect.any(Function),
125+
exportAs: expect.any(Function),
126+
}),
124127
});
125128
expect(createImportExportWorkspaceComponent).toHaveBeenCalledWith({
126129
root: global.document.getElementById('import-export-controls'),

jest.config.cjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
verbose: true,
3+
transform: {},
4+
testMatch: [
5+
'**/packages/core/src/tests/**/*.test.js',
6+
'**/packages/core-ui/src/tests/**/*.test.js',
7+
'**/tests/integration/**/*.test.js',
8+
'**/apps/web/src/tests/jest/**/*.test.js',
9+
],
10+
testPathIgnorePatterns: ['/node_modules/', '/tests/browser/', '/apps/web/src/tests/browser/'],
11+
modulePathIgnorePatterns: ['<rootDir>/build/'],
12+
collectCoverageFrom: ['packages/**/*.js', '!packages/core/js/libs/**'],
13+
moduleNameMapper: {
14+
'^@anywaydata/core$': '<rootDir>/packages/core/src/index.js',
15+
'^@anywaydata/core/(.*)$': '<rootDir>/packages/core/js/$1',
16+
'^@anywaydata/core/data_formats/(.*)$': '<rootDir>/packages/core/js/data_formats/$1',
17+
'https://cdn.skypack.dev/@faker-js/faker@v9.7.0': '@faker-js/faker',
18+
'https://unpkg.com/papaparse@5.5.2/papaparse.min.js': 'papaparse',
19+
'/libs/randexp.min.js': 'randexp',
20+
},
21+
};

package.json

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"apps/*"
1111
],
1212
"scripts": {
13-
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
14-
"testverbose": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --verbose",
15-
"testcoverage": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage",
13+
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.cjs",
14+
"testverbose": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.cjs --verbose",
15+
"testcoverage": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.cjs --coverage",
1616
"storybook": "storybook dev -p 6006",
1717
"build-storybook": "node ./scripts/run-build-storybook.mjs",
1818
"test:storybook": "node ./scripts/run-storybook-tests.mjs",
19-
"test:ui:jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js packages/core-ui/src/tests apps/web/src/tests/jest",
19+
"test:ui:jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.cjs --testPathPatterns packages/core-ui/src/tests apps/web/src/tests/jest",
2020
"testenv:create": "node ./scripts/create-testenv.mjs",
2121
"generate:faker-help": "node ./scripts/generate-faker-help.js",
2222
"test:browser": "node ./node_modules/@playwright/test/cli.js test",
@@ -38,7 +38,7 @@
3838
"build:web": "vite build --config ./apps/web/vite.config.mjs",
3939
"preview:web": "vite preview --config ./apps/web/vite.config.mjs",
4040
"serve:web": "pnpm run dev:web",
41-
"benchmark:tabulator": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js packages/core-ui/src/tests/grid/tabulator-performance.benchmark.test.js --runInBand",
41+
"benchmark:tabulator": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.cjs --runTestsByPath packages/core-ui/src/tests/grid/tabulator-performance.benchmark.test.js --runInBand",
4242
"anywaydata:mac": "pnpm --dir docs-src run anywaydata && pnpm run build:web && node ./scripts/merge-web-build-into-docs-build.js && cp -R ./build/ ../../anywaydata-com",
4343
"anywaydata:win": "pnpm --dir docs-src run anywaydata && pnpm run build:web && node .\\scripts\\merge-web-build-into-docs-build.js && echo cleaning anywaydata for deployment && ..\\anywaydata-com\\make-ready-for-prod.bat",
4444
"previewdocs": "pnpm --dir docs-src run start",
@@ -47,36 +47,6 @@
4747
"test:workspaces": "pnpm --workspace-concurrency=1 --filter @anywaydata/api --filter @anywaydata/cli --filter @anywaydata/mcp run test",
4848
"test:workspaces:all": "pnpm -r --if-present run test"
4949
},
50-
"jest": {
51-
"verbose": true,
52-
"transform": {},
53-
"testMatch": [
54-
"<rootDir>/packages/core/src/tests/**/*.test.js",
55-
"<rootDir>/packages/core-ui/src/tests/**/*.test.js",
56-
"<rootDir>/tests/integration/**/*.test.js",
57-
"<rootDir>/apps/web/src/tests/jest/**/*.test.js"
58-
],
59-
"testPathIgnorePatterns": [
60-
"/node_modules/",
61-
"/tests/browser/",
62-
"/apps/web/src/tests/browser/"
63-
],
64-
"modulePathIgnorePatterns": [
65-
"<rootDir>/build/"
66-
],
67-
"collectCoverageFrom": [
68-
"packages/**/*.js",
69-
"!packages/core/js/libs/**"
70-
],
71-
"moduleNameMapper": {
72-
"^@anywaydata/core$": "<rootDir>/packages/core/src/index.js",
73-
"^@anywaydata/core/(.*)$": "<rootDir>/packages/core/js/$1",
74-
"^@anywaydata/core/data_formats/(.*)$": "<rootDir>/packages/core/js/data_formats/$1",
75-
"https://cdn.skypack.dev/@faker-js/faker@v9.7.0": "@faker-js/faker",
76-
"https://unpkg.com/papaparse@5.5.2/papaparse.min.js": "papaparse",
77-
"/libs/randexp.min.js": "randexp"
78-
}
79-
},
8050
"repository": {
8151
"type": "git",
8252
"url": "git+https://github.com/eviltester/grid-table-editor.git"

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"scripts": {
2525
"build": "node -e \"console.log('core: no build step')\"",
26-
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --config ../../package.json --testMatch \"<rootDir>/packages/core/src/tests/**/*.test.js\""
26+
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --config ../../jest.config.cjs --testPathPatterns packages/core/src/tests"
2727
},
2828
"dependencies": {
2929
"@faker-js/faker": "9.7.0",

0 commit comments

Comments
 (0)