Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deps: Bump @babel/generator from 7.22.10 to 7.22.15 #496

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest-eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
module.exports = {
testEnvironment: 'node',
runner: 'jest-runner-eslint',
testSequencer: '<rootDir>/test/support/eslintSequencer.js',
testMatch: ['<rootDir>/**/*.(js|cjs|mjs|jsx)'],
// Jest by default uses a number of workers equal to number of CPU cores minus 1.
// Github Actions runners provide 2 cores and running with 2 workers is faster than 1.
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module.exports = {
'<rootDir>/test/support/register.js'
],
testSequencer: '<rootDir>/test/support/sequencer.js',
// Disable babel-jest transformation
transform: {},
// Jest by default uses a number of workers equal to number of CPU cores minus 1.
// Github Actions runners provide 2 cores and running with 2 workers is faster than 1.
...(process.env.CI && {maxWorkers: '100%'})
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@babel/core": "^7.22.11",
"@babel/generator": "^7.22.10",
"@babel/generator": "^7.22.15",
"@babel/helper-module-transforms": "^7.22.9",
"@babel/parser": "^7.22.13",
"@babel/plugin-transform-modules-commonjs": "^7.22.11",
Expand Down
26 changes: 26 additions & 0 deletions test/support/eslintSequencer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* --------------------
* livepack
* Custom test sequencer for Jest ESLint
* ------------------*/

'use strict';

// Modules
const fs = require('fs'),
Sequencer = require('@jest/test-sequencer').default;

// Exports

// Custom sequencer to ensure the largest files are run first.
// `jest-runner-eslint` doesn't seem to sequence automatically.
// https://github.com/jest-community/jest-runner-eslint/issues/204
// TODO: Remove this workaround once above issue is fixed.

module.exports = class CustomSequencer extends Sequencer {
sort(tests) {
tests = super.sort(tests);
const testsWithFileSizes = tests.map(test => ({test, size: fs.statSync(test.path).size}));
testsWithFileSizes.sort((t1, t2) => (t1.size > t2.size ? -1 : t1.size < t2.size ? 1 : 0));
return testsWithFileSizes.map(({test}) => test);
}
};
25 changes: 21 additions & 4 deletions test/support/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,39 @@
* Tests install require hook to intrument test files' code
* ------------------*/

/* eslint-disable import/order, import/newline-after-import */
/* eslint-disable import/order, import/no-dynamic-require, global-require */

'use strict';

// Imports
const {
useInternalModuleCache, useGlobalModuleCache, usingInternalModuleCache, Module
} = require('../../lib/shared/moduleCache.js');

// Patch filesystem for virtual fixtures files
require('./fixturesFs.js');

// Pre-load `fast-json-stable-stringify`.
// `jest-light-runner` imports `jest-snapshot` which requires `@jest/transform`.
// After `jest-light-runner`'s worker loads the test file, it runs a method on `jest-snapshot`
// which causes `@jest/transform` to lazily require `fast-json-stable-stringify`.
// Trigger this now, so `fast-json-stable-stringify` is not loaded later and unnecessarily instrumented.
// `createScriptTransformer()` when called with no arguments throws an error before it does anything.
const {createRequire} = Module,
jestLightRunnerPath = require.resolve('jest-light-runner'),
jestSnapshotPath = createRequire(jestLightRunnerPath).resolve('jest-snapshot'),
jestTransformPath = createRequire(jestSnapshotPath).resolve('@jest/transform');
if (Module._cache[jestTransformPath]) {
const jestTransform = require(jestTransformPath);
jestTransform.createScriptTransformer().catch(() => {});
}

// Install register require hook.
// Disable instrumentation cache. Tests run in multiple threads, so it'd be read from and written to
// concurrently unless disabled.
require('../../register.js')({cache: false});

// Use internal module cache to avoid transpiling modules
const {
useInternalModuleCache, useGlobalModuleCache, usingInternalModuleCache
} = require('../../lib/shared/moduleCache.js');
useInternalModuleCache();

// Modules
Expand Down
Loading