refactor: simplify jest config (#42136)
* refactor: bring api jest tests to root * refactor: pull client tests to root * fix: remove ancient curriculum babelrc * feat: run all jest tests at once * fix: remove unused babelrcRoot * chore: remove more jests
This commit is contained in:
committed by
GitHub
parent
8ba3b8c16c
commit
1c1d86922c
16
api-server/.babelrc
Normal file
16
api-server/.babelrc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{"targets": {
|
||||||
|
"node": 10
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"babel-plugin-transform-function-bind",
|
||||||
|
"@babel/plugin-proposal-class-properties",
|
||||||
|
"@babel/plugin-proposal-object-rest-spread",
|
||||||
|
"@babel/plugin-proposal-optional-chaining"
|
||||||
|
]
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
plugins: [
|
|
||||||
require.resolve('babel-plugin-transform-function-bind'),
|
|
||||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
|
||||||
require.resolve('@babel/plugin-proposal-object-rest-spread'),
|
|
||||||
require.resolve('@babel/plugin-proposal-optional-chaining')
|
|
||||||
],
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
require.resolve('@babel/preset-env'),
|
|
||||||
{
|
|
||||||
targets: {
|
|
||||||
node: '10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
};
|
|
@ -1,20 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
moduleNameMapper: {
|
|
||||||
'\\.(jpg|jpeg|png|svg|woff|woff2)$': '<rootDir>/src/__mocks__/fileMock.js',
|
|
||||||
// Plain CSS - match css files that don't end with
|
|
||||||
// '.module.css' https://regex101.com/r/VzwrKH/4
|
|
||||||
'^(?!.*\\.module\\.css$).*\\.css$': '<rootDir>/src/__mocks__/styleMock.js',
|
|
||||||
// CSS Modules - match files that end with 'module.css'
|
|
||||||
'\\.module\\.css$': 'identity-obj-proxy',
|
|
||||||
analytics: '<rootDir>/src/__mocks__/analyticsMock.js'
|
|
||||||
},
|
|
||||||
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/.cache/'],
|
|
||||||
globals: {
|
|
||||||
__PATH_PREFIX__: ''
|
|
||||||
},
|
|
||||||
verbose: true,
|
|
||||||
transform: {
|
|
||||||
'^.+\\.js$': 'babel-jest'
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)']
|
|
||||||
};
|
|
8490
api-server/package-lock.json
generated
8490
api-server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,8 +22,7 @@
|
|||||||
"babel-dev-server": "babel-node --inspect=0.0.0.0 ./src/server/index.js",
|
"babel-dev-server": "babel-node --inspect=0.0.0.0 ./src/server/index.js",
|
||||||
"build": "babel src --out-dir lib --ignore 'node_modules /**/*','/**/*.test.js' --copy-files --no-copy-ignored",
|
"build": "babel src --out-dir lib --ignore 'node_modules /**/*','/**/*.test.js' --copy-files --no-copy-ignored",
|
||||||
"develop": "cross-env DEBUG=fcc* node src/development-start.js",
|
"develop": "cross-env DEBUG=fcc* node src/development-start.js",
|
||||||
"start": "cross-env DEBUG=fcc* node lib/production-start.js",
|
"start": "cross-env DEBUG=fcc* node lib/production-start.js"
|
||||||
"test": "jest"
|
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"babel-core": "7.0.0-bridge.0"
|
"babel-core": "7.0.0-bridge.0"
|
||||||
@ -82,10 +81,8 @@
|
|||||||
"@babel/preset-env": "^7.13.15",
|
"@babel/preset-env": "^7.13.15",
|
||||||
"@babel/register": "^7.13.14",
|
"@babel/register": "^7.13.14",
|
||||||
"babel-core": "^7.0.0-bridge.0",
|
"babel-core": "^7.0.0-bridge.0",
|
||||||
"babel-jest": "^24.9.0",
|
|
||||||
"babel-plugin-transform-function-bind": "^6.22.0",
|
"babel-plugin-transform-function-bind": "^6.22.0",
|
||||||
"babel-plugin-transform-imports": "^1.5.1",
|
"babel-plugin-transform-imports": "^1.5.1",
|
||||||
"jest": "^26.6.3",
|
|
||||||
"loopback-component-explorer": "^6.4.0",
|
"loopback-component-explorer": "^6.4.0",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.7",
|
||||||
"smee-client": "^1.2.2"
|
"smee-client": "^1.2.2"
|
||||||
|
1
babel.config.js
Normal file
1
babel.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = { babelrcRoots: ['./api-server', './client'] };
|
@ -31,7 +31,7 @@ const filesThatShouldExist = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const path = `${process.cwd()}/i18n/locales`;
|
const path = `${__dirname}/locales`;
|
||||||
|
|
||||||
describe('Locale tests:', () => {
|
describe('Locale tests:', () => {
|
||||||
availableLangs.client.forEach(lang => {
|
availableLangs.client.forEach(lang => {
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
moduleNameMapper: {
|
|
||||||
'\\.(jpg|jpeg|png|svg|woff|woff2)$': '<rootDir>/src/__mocks__/fileMock.js',
|
|
||||||
// Plain CSS - match css files that don't end with
|
|
||||||
// '.module.css' https://regex101.com/r/VzwrKH/4
|
|
||||||
'^(?!.*\\.module\\.css$).*\\.css$': '<rootDir>/src/__mocks__/styleMock.js',
|
|
||||||
// CSS Modules - match files that end with 'module.css'
|
|
||||||
'\\.module\\.css$': 'identity-obj-proxy',
|
|
||||||
'react-i18next': '<rootDir>/src/__mocks__/react-i18nextMock.js',
|
|
||||||
'^lodash-es$': 'lodash'
|
|
||||||
},
|
|
||||||
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/.cache/'],
|
|
||||||
globals: {
|
|
||||||
__PATH_PREFIX__: ''
|
|
||||||
},
|
|
||||||
verbose: true,
|
|
||||||
transform: {
|
|
||||||
'^.+\\.js$': '<rootDir>/jest.transform.js'
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)'],
|
|
||||||
setupFilesAfterEnv: ['./jest.setup.js']
|
|
||||||
};
|
|
@ -1,17 +0,0 @@
|
|||||||
const babelOptions = {
|
|
||||||
presets: ['@babel/preset-env', '@babel/react'],
|
|
||||||
plugins: [
|
|
||||||
'@babel/plugin-proposal-function-bind',
|
|
||||||
[
|
|
||||||
'transform-imports',
|
|
||||||
{
|
|
||||||
'@freecodecamp/react-bootstrap': {
|
|
||||||
transform: '@freecodecamp/react-bootstrap/lib/${member}',
|
|
||||||
preventFullImport: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = require('babel-jest').createTransformer(babelOptions);
|
|
5028
client/package-lock.json
generated
5028
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,6 @@
|
|||||||
"serve": "gatsby serve -p 8000",
|
"serve": "gatsby serve -p 8000",
|
||||||
"prestand-alone": "npm run prebuild",
|
"prestand-alone": "npm run prebuild",
|
||||||
"stand-alone": "gatsby develop",
|
"stand-alone": "gatsby develop",
|
||||||
"test": "jest",
|
|
||||||
"validate-keys": "node ./i18n/validate-keys.js"
|
"validate-keys": "node ./i18n/validate-keys.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -130,7 +129,6 @@
|
|||||||
"chokidar": "3.5.1",
|
"chokidar": "3.5.1",
|
||||||
"copy-webpack-plugin": "8.1.1",
|
"copy-webpack-plugin": "8.1.1",
|
||||||
"gatsby-plugin-webpack-bundle-analyser-v2": "1.1.22",
|
"gatsby-plugin-webpack-bundle-analyser-v2": "1.1.22",
|
||||||
"jest": "26.6.3",
|
|
||||||
"jest-json-schema-extended": "1.0.0",
|
"jest-json-schema-extended": "1.0.0",
|
||||||
"monaco-editor-webpack-plugin": "3.1.0",
|
"monaco-editor-webpack-plugin": "3.1.0",
|
||||||
"react-test-renderer": "16.14.0",
|
"react-test-renderer": "16.14.0",
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": [ "env", "react", "stage-0" ],
|
|
||||||
"plugins": [
|
|
||||||
"transform-runtime",
|
|
||||||
"lodash"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,5 +1,26 @@
|
|||||||
// TODO: remove this once /tools/dashboard's tests are configured correctly
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
testPathIgnorePatterns: ['/node_modules/', '/tools/dashboard']
|
// TODO: remove /tools/dashboard when the tests are configured correctly
|
||||||
|
testPathIgnorePatterns: ['/node_modules/', '/tools/dashboard'],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'\\.(jpg|jpeg|png|svg|woff|woff2)$':
|
||||||
|
'<rootDir>/client/src/__mocks__/fileMock.js',
|
||||||
|
// Plain CSS - match css files that don't end with
|
||||||
|
// '.module.css' https://regex101.com/r/VzwrKH/4
|
||||||
|
'^(?!.*\\.module\\.css$).*\\.css$':
|
||||||
|
'<rootDir>/client/src/__mocks__/styleMock.js',
|
||||||
|
// CSS Modules - match files that end with 'module.css'
|
||||||
|
'\\.module\\.css$': 'identity-obj-proxy',
|
||||||
|
'react-i18next': '<rootDir>/client/src/__mocks__/react-i18nextMock.js',
|
||||||
|
'^lodash-es$': 'lodash'
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
__PATH_PREFIX__: ''
|
||||||
|
},
|
||||||
|
verbose: true,
|
||||||
|
transform: {
|
||||||
|
'^.+\\.js$': '<rootDir>/jest.transform.js'
|
||||||
|
},
|
||||||
|
roots: ['.', './client', './api-server'],
|
||||||
|
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)'],
|
||||||
|
setupFilesAfterEnv: ['./jest.setup.js']
|
||||||
};
|
};
|
||||||
|
15
jest.transform.js
Normal file
15
jest.transform.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const babelOptions = {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 14
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@babel/react'
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = require('babel-jest').createTransformer(babelOptions);
|
1327
package-lock.json
generated
1327
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -76,13 +76,14 @@
|
|||||||
"start:server": "cd ./api-server && npm start",
|
"start:server": "cd ./api-server && npm start",
|
||||||
"storybook": "cd ./tools/ui-components && npm run storybook",
|
"storybook": "cd ./tools/ui-components && npm run storybook",
|
||||||
"test": "run-s ensure-env build:curriculum build-workers test:*",
|
"test": "run-s ensure-env build:curriculum build-workers test:*",
|
||||||
"test-curriculum-full-output": "cd ./curriculum && npm run test:full-output",
|
"test:source": "jest",
|
||||||
"test:client": "cd ./client && npm test",
|
|
||||||
"test:curriculum": "cd ./curriculum && npm test",
|
"test:curriculum": "cd ./curriculum && npm test",
|
||||||
"test:curriculum-js": "jest --rootDir ./curriculum",
|
"test-curriculum-full-output": "cd ./curriculum && npm run test:full-output",
|
||||||
"test:server": "cd ./api-server && npm test",
|
"test-client": "jest client",
|
||||||
"test:tools": "jest ./tools",
|
"test-curriculum-js": "jest curriculum",
|
||||||
"test:utils": "jest --rootDir ./utils",
|
"test-server": "jest api-server",
|
||||||
|
"test-tools": "jest tools",
|
||||||
|
"test-utils": "jest utils",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
@ -95,8 +96,13 @@
|
|||||||
"invariant": "2.2.4"
|
"invariant": "2.2.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/plugin-proposal-function-bind": "^7.12.13",
|
||||||
|
"@babel/preset-env": "^7.14.2",
|
||||||
|
"@babel/preset-react": "^7.13.13",
|
||||||
"@testing-library/cypress": "7.0.6",
|
"@testing-library/cypress": "7.0.6",
|
||||||
|
"@testing-library/jest-dom": "^5.12.0",
|
||||||
"babel-eslint": "10.1.0",
|
"babel-eslint": "10.1.0",
|
||||||
|
"babel-plugin-transform-imports": "^2.0.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cypress": "7.3.0",
|
"cypress": "7.3.0",
|
||||||
"docsify-cli": "4.4.3",
|
"docsify-cli": "4.4.3",
|
||||||
|
4776
tools/scripts/build/package-lock.json
generated
4776
tools/scripts/build/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,8 @@
|
|||||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
||||||
"author": "freeCodeCamp <team@freecodecamp.org>",
|
"author": "freeCodeCamp <team@freecodecamp.org>",
|
||||||
"main": "none",
|
"main": "none",
|
||||||
"scripts": {
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"debug": "4.3.1",
|
"debug": "4.3.1",
|
||||||
"dotenv": "9.0.2",
|
"dotenv": "9.0.2"
|
||||||
"jest": "26.6.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4740
tools/scripts/seed/package-lock.json
generated
4740
tools/scripts/seed/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -18,13 +18,9 @@
|
|||||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
||||||
"author": "freeCodeCamp <team@freecodecamp.org>",
|
"author": "freeCodeCamp <team@freecodecamp.org>",
|
||||||
"main": "none",
|
"main": "none",
|
||||||
"scripts": {
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"debug": "4.3.1",
|
"debug": "4.3.1",
|
||||||
"dotenv": "9.0.2",
|
"dotenv": "9.0.2",
|
||||||
"jest": "26.6.3",
|
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"mongodb": "3.6.6"
|
"mongodb": "3.6.6"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user