1 Star 0 Fork 0

Cloudy/core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
jest.config.js 3.87 KB
一键复制 编辑 原始数据 按行查看 历史
John 提交于 2024-03-12 10:24 . chore: upgrade monaco version 0.45.0 (#3257)
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)',
],
},
],
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/itcloudy/core.git
git@gitee.com:itcloudy/core.git
itcloudy
core
core
main

搜索帮助