Add support for Jest runner
Summary: This diff adds compatibility with https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest and makes sure the `yarn jest` command works without further arguments by defaulting to the unit test setup. This makes tests runnable from VSCode, highlights which tests passed, and show errors inline (and coverage as well if desired), and will report failing tests in the problems panel. {F235815220} The debugger can be started right from the code pane as well by clicking the tiny 'debug' {F235815208} Currently set up the defaults to not start tests after startup, as it can be CPU hogging, so simply run the command CMD+SHIFT+P 'start jest runner' instead. Reviewed By: passy Differential Revision: D21325241 fbshipit-source-id: 7b87297a710a18bbac394110dc2006218ccc7d86
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b474ef24e0
commit
5db7820820
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -26,5 +26,10 @@
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
}
|
||||
},
|
||||
"jest.autoEnable": false,
|
||||
"jest.enableInlineErrorMessages": true,
|
||||
"jest.runAllTestsFirst": false,
|
||||
"jest.pathToConfig": "desktop/jest.config.js",
|
||||
"jest.pathToJest": "desktop/node_modules/.bin/jest"
|
||||
}
|
||||
|
||||
7
desktop/.vscode/settings.json
vendored
7
desktop/.vscode/settings.json
vendored
@@ -26,5 +26,10 @@
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
}
|
||||
},
|
||||
"jest.autoEnable": false,
|
||||
"jest.enableInlineErrorMessages": true,
|
||||
"jest.runAllTestsFirst": false,
|
||||
"jest.pathToConfig": "jest.config.js",
|
||||
"jest.pathToJest": "node_modules/.bin/jest"
|
||||
}
|
||||
|
||||
26
desktop/jest.config.js
Normal file
26
desktop/jest.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
transform: {
|
||||
'^.*__tests__/.*\\.tsx?$': 'ts-jest',
|
||||
'\\.(js|tsx?)$': '<rootDir>/scripts/jest-transform.js',
|
||||
},
|
||||
setupFiles: ['<rootDir>/scripts/jest-setup.js'],
|
||||
moduleNameMapper: {
|
||||
'^flipper$': '<rootDir>/app/src',
|
||||
'^flipper-doctor$': '<rootDir>/doctor/src',
|
||||
'^flipper-pkg$': '<rootDir>/pkg/src',
|
||||
'^flipper-pkg-lib$': '<rootDir>/pkg-lib/src',
|
||||
},
|
||||
clearMocks: true,
|
||||
coverageReporters: ['json-summary', 'lcov', 'html'],
|
||||
testMatch: ['**/**.node.(js|jsx|ts|tsx)'],
|
||||
testEnvironment: 'jest-environment-jsdom-sixteen',
|
||||
};
|
||||
@@ -91,27 +91,6 @@
|
||||
"ws": "7.2.3",
|
||||
"kind-of": "6.0.3"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.*__tests__/.*\\.tsx?$": "ts-jest",
|
||||
"\\.(js|tsx?)$": "<rootDir>/scripts/jest-transform.js"
|
||||
},
|
||||
"setupFiles": [
|
||||
"<rootDir>/scripts/jest-setup.js"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"^flipper$": "<rootDir>/app/src",
|
||||
"^flipper-doctor$": "<rootDir>/doctor/src",
|
||||
"^flipper-pkg$": "<rootDir>/pkg/src",
|
||||
"^flipper-pkg-lib$": "<rootDir>/pkg-lib/src"
|
||||
},
|
||||
"clearMocks": true,
|
||||
"coverageReporters": [
|
||||
"json-summary",
|
||||
"lcov",
|
||||
"html"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/code-frame": "^7.8.3",
|
||||
"@jest-runner/electron": "^2.0.2",
|
||||
@@ -241,10 +220,11 @@
|
||||
"build-headless": "cross-env NODE_ENV=production ./ts-node scripts/build-headless.ts $@",
|
||||
"open-dist": "open ../dist/mac/Flipper.app --args --launcher=false --inspect=9229",
|
||||
"fix": "eslint . --fix --ext .js,.ts,.tsx",
|
||||
"test": "yarn build:pkg && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"node\\.(js|ts|tsx)$\" --no-cache",
|
||||
"test:debug": "yarn build:pkg && node --inspect node_modules/.bin/jest --runInBand --env=jest-environment-jsdom-sixteen",
|
||||
"test-electron": "yarn build:pkg && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"electron\\.(js|ts|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",
|
||||
"test-with-device": "yarn build:pkg && USE_ELECTRON_STUBS=1 jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"device\\.(js|ts|tsx)$\" --detectOpenHandles --no-cache",
|
||||
"pretest": "yarn build:pkg",
|
||||
"test": "jest",
|
||||
"test:debug": "yarn build:pkg && node --inspect node_modules/.bin/jest --runInBand",
|
||||
"test-electron": "yarn build:pkg && jest --testMatch=\"**/**.electron\\.(js|jsx|ts|tsx)\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron",
|
||||
"test-with-device": "yarn build:pkg && USE_ELECTRON_STUBS=1 jest --testMatch=\"**/**.device\\.(js|jsx|ts|tsx)\" --detectOpenHandles",
|
||||
"test-e2e": "cd e2e && yarn test",
|
||||
"lint:tsc": "tsc --noemit",
|
||||
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
|
||||
|
||||
Reference in New Issue
Block a user