Skip to content

Commit 1944dbe

Browse files
committed
refactor: retrofit debug system with latest vscode features and extensions
1 parent b6f3f28 commit 1944dbe

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
// * Used by Jest and `npm test`
1818
test: {
1919
comments: true,
20-
sourceMaps: 'both',
20+
sourceMaps: process.env.JEST_TRANSPILED ? false : 'inline',
2121
presets: [
2222
['@babel/preset-env', { targets: { node: true } }],
2323
['@babel/preset-typescript', { allowDeclareFields: true }]

jest.config.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,23 @@ module.exports = {
2020
// ? Minimum of 2 concurrent tests executed at once; maximum of cpu cores - 1
2121
maxConcurrency: Math.max(require('node:os').cpus().length - 1, 2),
2222
verbose: false,
23-
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
23+
// ! '/.transpiled/' MUST ALWAYS be the last element in this array
24+
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/.transpiled/'],
2425
setupFilesAfterEnv: ['./test/setup.ts'],
2526
collectCoverageFrom: ['src/**/*.ts?(x)'],
2627
// ? Make sure jest-haste-map doesn't try to parse and cache fixtures
27-
modulePathIgnorePatterns: ['<rootDir>/test/fixtures']
28+
modulePathIgnorePatterns: ['/test/fixtures/', '/.transpiled/test/fixtures/']
2829
};
30+
31+
if (process.env.JEST_TRANSPILED) {
32+
module.exports.testPathIgnorePatterns.pop();
33+
module.exports.roots = ['<rootDir>/.transpiled/'];
34+
}
35+
36+
if (process.env.JEST_IGNORE_UNITS) {
37+
module.exports.testPathIgnorePatterns.push('unit-.*\\.test\\.ts.*');
38+
}
39+
40+
if (!process.env.JEST_NO_IGNORE_INTEGRATIONS) {
41+
module.exports.testPathIgnorePatterns.push('integration-.*\\.test\\.ts.*');
42+
}

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@
6262
"list-tasks": "node -e 'console.log(Object.keys(require(\"./package.json\").scripts).join(\"\\n\"))' && (npm run -ws list-tasks --if-present 2>/dev/null || true)",
6363
"prepare": "node -e \"execa = require('execa'); if(process.env.CI === undefined && (process.env.NODE_ENV === undefined || process.env.NODE_ENV === 'development')) { execa.sync('npx', ['husky', 'install'], { stdout: 'inherit', stderr: 'inherit' }); } else { console.log('skipped installing husky git hooks'); }\"",
6464
"test": "npm run test:unit --",
65-
"test:all": "npx attw --pack . && echo && npm run test:base -- --coverage",
65+
"test:all": "JEST_NO_IGNORE_INTEGRATIONS=true npm run test:base -- --coverage",
6666
"test:base": "NODE_OPTIONS='--no-warnings --experimental-vm-modules' NODE_ENV=test jest",
67-
"test:integration": "npm run test:base -- 'integration.*?\\.test\\.tsx?'",
67+
"test:integration": "JEST_NO_IGNORE_INTEGRATIONS=true JEST_IGNORE_UNITS=true npm run test:base -- 'integration-.*\\.test\\.ts.*'",
6868
"test:transpiled": "JEST_TRANSPILED=true npm run test:base --",
6969
"test:unit": "npm run test:base -- 'unit-.*\\.test\\.tsx?'",
70-
"test:update": "npm run test:all -- --updateSnapshot"
70+
"test:update": "npm run test:all -- --updateSnapshot",
71+
"test:repeat:all": "echo 'Repeating test suite [initializing]...'; (i=0; while [ \"$((( i += 1 ) <= 100 ))\" -ne 0 ]; do sleep 0.1 && echo \"\\r\\033[1A\\033[0KRepeating test suite [run $i/100]...\" && JEST_SILENT_REPORTER_SHOW_WARNINGS=true npx run test:all --reporters=jest-silent-reporter || exit; done) && echo \"All tests passed! Congrats!\"",
72+
"test:repeat:unit": "echo 'Repeating test suite [initializing]...'; (i=0; while [ \"$((( i += 1 ) <= 100 ))\" -ne 0 ]; do sleep 0.1 && echo \"\\r\\033[1A\\033[0KRepeating test suite [run $i/100]...\" && JEST_SILENT_REPORTER_SHOW_WARNINGS=true npx run test:unit --reporters=jest-silent-reporter || exit; done) && echo \"All tests passed! Congrats!\""
7173
},
7274
"dependencies": {
7375
"core-js": "^3.35.1",

test/integration/integration-node-interop.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
/* eslint-disable jest/no-conditional-in-test, jest/no-conditional-expect */
33

44
// * These are tests that ensure babel-plugin-tester works (1) in ESM vs CJS
5-
// * environments, (2) using modern vs modern-default vs default vs dot-default
6-
// * import syntax, (3) using main vs pure import specifiers, (4) across all
7-
// * maintained versions of NodeJS.
5+
// * environments, (2) using modern import syntax, (3) using main vs pure import
6+
// * specifiers, (4) across all maintained versions of NodeJS.
87

98
import debugFactory from 'debug';
109
import mergeWith from 'lodash.mergewith';

test/integration/test-config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const IMPORT_SPECIFIERS_UNDER_TEST = ([
4444

4545
/* prettier-ignore */
4646
export const IMPORT_STYLES_UNDER_TEST = ([
47-
'modern', // ? import { pluginTester } from '...' (and CJS version)
47+
'modern', // ? import { pluginTester } from '...' (and CJS version)
4848
//'modern-default', // ? import { default: pluginTester } from '...' (and CJS version)
4949
//'default', // ? import pluginTester from '...' (and CJS version)
5050
//'dot-default' // ? const pluginTester = require('...').default
@@ -54,7 +54,8 @@ export const IMPORT_STYLES_UNDER_TEST = ([
5454
export const BABEL_VERSIONS_UNDER_TEST = ([
5555
// * [babel@version, ...otherPackages]
5656
['@babel/core@7.11.6'], // ? Current minimum version
57-
['@babel/core@latest'] // ? Latest version
57+
['@babel/core@latest'], // ? Latest version
58+
['@babel/core@next'], // ? Next version
5859
]);
5960

6061
// * [node@version, ...]
@@ -70,7 +71,7 @@ export const NODE_VERSIONS_UNDER_TEST = browserslist('maintained node versions')
7071

7172
export const FRAMEWORKS_UNDER_TEST: FrameworksUnderTest = [
7273
{
73-
frameworkPkg: 'jest@latest',
74+
frameworkPkg: 'jest@>=30 || >=30.0.0-alpha.2',
7475
frameworkArgs: ['jest'],
7576
tests: [
7677
{ source: assets.invocation, expectations: expectSuccessAndOutput },

0 commit comments

Comments
 (0)