mirror of
https://github.com/yldio/copilot.git
synced 2024-11-16 00:00:06 +02:00
52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
|
#!/usr/bin/env node
|
||
|
|
||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||
|
process.env.BABEL_ENV = 'test';
|
||
|
process.env.NODE_ENV = 'test';
|
||
|
process.env.PUBLIC_URL = '';
|
||
|
|
||
|
// Makes the script crash on unhandled rejections instead of silently
|
||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||
|
// terminate the Node.js process with a non-zero exit code.
|
||
|
process.on('unhandledRejection', err => {
|
||
|
throw err;
|
||
|
});
|
||
|
|
||
|
// Ensure environment variables are read.
|
||
|
require('react-scripts/config/env');
|
||
|
|
||
|
const jest = require('jest');
|
||
|
const argv = process.argv.slice(2);
|
||
|
|
||
|
// Watch unless on CI or in coverage mode
|
||
|
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
|
||
|
argv.push('--watch');
|
||
|
}
|
||
|
|
||
|
// This is not necessary after eject because we embed config into package.json.
|
||
|
const createJestConfig = require('react-scripts/scripts/utils/createJestConfig');
|
||
|
const path = require('path');
|
||
|
const paths = require('react-scripts/config/paths');
|
||
|
|
||
|
const config = createJestConfig(
|
||
|
relativePath =>
|
||
|
path.resolve(__dirname, '../node_modules/react-scripts', relativePath),
|
||
|
path.resolve(__dirname, '..'),
|
||
|
false
|
||
|
);
|
||
|
|
||
|
// patch
|
||
|
config.testEnvironment = 'node';
|
||
|
config.testMatch = ['<rootDir>/test/(unit|integration)/*.js'];
|
||
|
config.moduleNameMapper = Object.assign({}, config.moduleNameMapper, {
|
||
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/test/file-mock.js',
|
||
|
'^root/(.*)$': '<rootDir>/src/$1',
|
||
|
'^@components/(.*)$': '<rootDir>/src/components/$1',
|
||
|
'^@assets/(.*)$': '<rootDir>/src/assets/$1',
|
||
|
'^@state/(.*)$': '<rootDir>/src/state/$1'
|
||
|
});
|
||
|
|
||
|
argv.push('--config', JSON.stringify(config));
|
||
|
|
||
|
jest.run(argv);
|