代码拉取完成,页面将自动刷新
const { pathsToModuleNameMapper } = require('ts-jest');
const tsconfig = require('./configs/ts/tsconfig.resolve.json');
const tsModuleNameMapper = pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: '<rootDir>/configs/' });
/**
* @type {import('@jest/types').Config.InitialOptions}
*/
const baseConfig = {
preset: 'ts-jest',
testRunner: 'jest-jasmine2',
resolver: '<rootDir>/tools/dev-tool/src/jest-resolver.js',
// https://dev.to/vantanev/make-your-jest-tests-up-to-20-faster-by-changing-a-single-setting-i36
maxWorkers: 2,
collectCoverageFrom: [
'packages/*/src/**/*.ts',
'!packages/**/*.contribution.ts',
// 部分contribution文件为-contribution结尾
'!packages/**/*-contribution.ts',
'!packages/startup/**/*.ts',
// Test 功能暂未完成
'!packages/testing/**/*.ts',
// CLI 不需要测试
'!packages/remote-cli/**/*.ts',
'!packages/core-electron-main/**/*.ts',
'!packages/*/src/electron-main/**/*.ts',
],
moduleNameMapper: {
...tsModuleNameMapper,
'^vscode-languageserver-types$': '<rootDir>/node_modules/vscode-languageserver-types/lib/umd/main.js',
'^ws$': '<rootDir>/node_modules/ws/index.js',
'.*\\.(css|less)$': '<rootDir>/tools/dev-tool/src/mock-exports.js',
},
testPathIgnorePatterns: [
'/dist/',
'/node_modules/',
'/tools/workspace/',
'/tools/template/',
'/tools/extensions/',
'/packages/status-bar/entry',
'/packages/startup/entry',
'/__mocks__/',
'/packages/quick-open/entry',
// 终端渲染测试暂时不跟随单元测试
'/packages/terminal-next/__tests__/browser/render.test.ts',
],
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/tools/workspace/'],
coveragePathIgnorePatterns: [
'/dist/',
'/node_modules/',
'/mocks/',
'/tools/template/',
'/tools/workspace/',
'/packages/startup/entry',
],
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0,
},
},
};
if (process.env.JEST_COVERAGE_PROVIDER) {
baseConfig.coverageProvider = process.env.JEST_COVERAGE_PROVIDER;
}
/**
* @type {import('@jest/types').Config.InitialOptions}
*/
module.exports = {
...baseConfig,
projects: [
{
...baseConfig,
displayName: 'node',
testEnvironment: 'node',
setupFiles: ['./jest.setup.node.js'],
testMatch: [
// 有个 webview 的 case 应该放在 electron 下测,也会被第一条规则匹配到
// - packages/webview/__tests__/webview/webview.channel.test.ts
'**/packages/*/__test?(s)__/!(browser)/**/?(*.)+(spec|test).[jt]s?(x)',
'**/packages/{core-common,core-electron-main,core-node,utils,i18n}/__tests__/**/?(*.)+(spec|test).[jt]s?(x)',
// exclude 的要放最后
'!**/packages/{components,core-browser}/__tests__/**',
'!**/packages/extension/__tests__/hosted/**',
],
},
{
...baseConfig,
displayName: 'jsdom',
testEnvironment: 'jsdom',
testEnvironmentOptions: {
html: `<html>
<body>
<div id="main"></div>
</body>
</html>`,
runScripts: 'dangerously',
url: 'http://localhost/?id=1',
userAgent: `Mozilla/5.0 (${
process.platform === 'darwin' ? 'Macintosh' : process.platform === 'win32' ? 'Windows' : 'Linux'
}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/v16.7.0`,
},
setupFiles: ['./jest.setup.jsdom.js'],
testMatch: [
'**/packages/*/__test?(s)__/browser/**/?(*.)+(spec|test).[jt]s?(x)',
'**/packages/*/__test?(s)__/common/**/?(*.)+(spec|test).[jt]s?(x)',
'**/tools/*/__tests__/**/?(*.)+(spec|test).[jt]s?(x)',
'**/packages/extension/__tests__/hosted/**/?(*.)+(spec|test).[jt]s?(x)',
'**/packages/{components,core-browser,core-common,electron-basic}/__tests__/**/?(*.)+(spec|test).[jt]s?(x)',
],
},
],
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。