Skip to content

Commit

Permalink
[ADD] Suport helpers for long tests triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
gdomenech98 committed Feb 5, 2024
1 parent 6663fa3 commit dff4698
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 22 deletions.
9 changes: 3 additions & 6 deletions apps/next/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
const baseJestConfig = require('./jest/jest.config.base.js');
module.exports = {
...baseJestConfig,
transform: {
'^.+\\.test.ts?$': [
'ts-jest',
{ tsconfig: './tests/tsconfig.json' },
],
},
preset: "ts-jest",
testEnvironment: "node",
testMatch: [
"<rootDir>/tests/**/*.test.ts"
]
}
};
9 changes: 9 additions & 0 deletions apps/next/jest/jest-globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// jest-globals.d.ts
declare global {
function describeLongTest(name: string, fn: () => void): void;
namespace describeLongTest {
var skip: (name: string, fn: () => void) => void;
}
}

export {};
10 changes: 10 additions & 0 deletions apps/next/jest/jest.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path');
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
setupFilesAfterEnv: [path.resolve(__dirname, 'jest.setup.js')],
detectOpenHandles: true,
testMatch: [
"<rootDir>/**/*.test.ts"
]
};
9 changes: 9 additions & 0 deletions apps/next/jest/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global.describeLongTest = (name, fn) => {
if (process.env.LONG_TESTS === "true") {
describe(name, fn);
}
};

global.describeLongTest.skip = (name, fn) => {
describe.skip(name, fn);
};
2 changes: 1 addition & 1 deletion apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "cd ../.. && yarn build && cd apps/next && next build",
"serve": "NODE_ENV=production next start --port 4000",
"lint": "next lint",
"test": "yarn test:deps && jest --colors --detectOpenHandles",
"test": "yarn test:deps && jest",
"test:deps": "npx playwright install && npx playwright install-deps"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion apps/next/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
".next/types/**/*.ts",
"jest/jest-globals.d.ts"
],
"exclude": [
"node_modules"
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
"stop": "pm2 stop all",
"logs": "pm2 logs",
"create-environment": "node copy.js",
"test:all": "yarn workspaces foreach run test",
"test:all:debug": "TEST_DEBUG=true yarn test:all",
"test:global": "yarn workspace tests test",
"test:all:long": "LONG_TESTS=true yarn test:all",
"test:all": "FORCE_COLOR=1 yarn workspaces foreach run test",
"test:all:debug": "FORCE_COLOR=1 TEST_DEBUG=true yarn test:all",
"test:global": "FORCE_COLOR=1 yarn workspace tests test",
"test:e2egen": "npx playwright codegen"
},
"resolutions": {
Expand Down
8 changes: 7 additions & 1 deletion packages/visualui/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const path = require('path');
module.exports = {
preset: "ts-jest",
testEnvironment: "node"
testEnvironment: "node",
setupFilesAfterEnv: [path.resolve(__dirname, 'jest', 'jest.setup.js')],
detectOpenHandles: true,
testMatch: [
"<rootDir>/**/*.test.ts"
]
};
9 changes: 9 additions & 0 deletions packages/visualui/jest/jest-globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// jest-globals.d.ts
declare global {
function describeLongTest(name: string, fn: () => void): void;
namespace describeLongTest {
var skip: (name: string, fn: () => void) => void;
}
}

export {};
9 changes: 9 additions & 0 deletions packages/visualui/jest/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global.describeLongTest = (name, fn) => {
if (process.env.LONG_TESTS === "true") {
describe(name, fn);
}
};

global.describeLongTest.skip = (name, fn) => {
describe.skip(name, fn);
};
2 changes: 1 addition & 1 deletion packages/visualui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"pull": "git pull",
"start": "ts-node src/index.ts",
"test": "jest --colors --detectOpenHandles"
"test": "jest"
},
"dependencies": {
"@craftjs/core": "0.2.0-beta.8",
Expand Down
3 changes: 2 additions & 1 deletion packages/visualui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
"src/**/*.tsx",
"jest/jest-globals.d.ts"
],
"exclude": [
"node_modules"
Expand Down
10 changes: 8 additions & 2 deletions tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const path = require('path');
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
preset: "ts-jest",
testEnvironment: "node",
setupFilesAfterEnv: [path.resolve(__dirname, "jest", 'jest.setup.js')],
detectOpenHandles: true,
testMatch: [
"<rootDir>/**/*.test.ts"
]
};
9 changes: 9 additions & 0 deletions tests/jest/jest-globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// jest-globals.d.ts
declare global {
function describeLongTest(name: string, fn: () => void): void;
namespace describeLongTest {
var skip: (name: string, fn: () => void) => void;
}
}

export {};
9 changes: 9 additions & 0 deletions tests/jest/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global.describeLongTest = (name, fn) => {
if (process.env.LONG_TESTS === "true") {
describe(name, fn);
}
};

global.describeLongTest.skip = (name, fn) => {
describe.skip(name, fn);
};
2 changes: 1 addition & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"test": "jest --colors --detectOpenHandles"
"test": "jest"
},
"devDependencies": {
"@jest/globals": "~29.7.0",
Expand Down
1 change: 1 addition & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"include": [
"**/*.ts",
"**/*.tsx",
"jest/jest-globals.d.ts"
]
}
20 changes: 15 additions & 5 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@
"sourceMap": false,
"strictNullChecks": false,
"target": "es2020",
"types": ["node"],
"lib": ["dom", "esnext"]
"types": [
"node"
],
"lib": [
"dom",
"esnext"
]
},
"exclude": ["_"],
"exclude": [
"_"
],
"typeAcquisition": {
"enable": true
}
}
},
"include": [
"./jest-globals.d.ts"
]
}

0 comments on commit dff4698

Please sign in to comment.