@jest/types#Config TypeScript Examples
The following examples show how to use
@jest/types#Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: executor.ts From nx-plugins with MIT License | 6 votes |
async function runJest(
baseUrl: string,
options: JestPlaywrightExecutorSchema,
parsedConfig: Config.Argv,
fileConfig: Config.Argv,
) {
const { slowMo, devtools, headless, browsers, timeout } = options;
const { testEnvironmentOptions = {}, globals = {} } = fileConfig;
const jestPlaywrightOptions = testEnvironmentOptions['jest-playwright'] || {};
const jestPlaywrightLaunchOptions = jestPlaywrightOptions.launchOptions || {};
const config: Config.Argv = {
...parsedConfig,
globals: JSON.stringify({ ...globals, baseUrl }),
testEnvironmentOptions: JSON.stringify({
...(testEnvironmentOptions as Record<string, unknown>),
'jest-playwright': {
...jestPlaywrightOptions,
browsers: browsers ?? jestPlaywrightOptions.browsers,
launchOptions: {
...jestPlaywrightLaunchOptions,
headless: devtools ? false : headless ?? jestPlaywrightLaunchOptions.headless,
devtools: devtools ?? jestPlaywrightLaunchOptions.devtools,
slowMo: slowMo ?? jestPlaywrightLaunchOptions.slowMo,
timeout: timeout ?? jestPlaywrightLaunchOptions.timeout,
},
},
}),
watch: options.watch,
watchAll: options.watchAll,
};
const { results } = await runCLI(config, [options.jestConfig]);
return results.success;
}
Example #2
Source File: build.jest.testRunner.ts From askql with MIT License | 6 votes |
async function buildFile(
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
environment: JestEnvironment,
runtime: JestRuntime,
testPath: string
): Promise<TestResult> {
return jasmine2(
globalConfig,
config,
Object.assign(environment, {
global: Object.assign(environment.global, {
jestTestPath: testPath,
}),
}),
runtime,
require.resolve('./jest-build-test')
);
}
Example #3
Source File: jest.config.ts From Cromwell with MIT License | 6 votes |
config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: "jsdom",
moduleNameMapper: {
"\\.s?css$": "identity-obj-proxy",
},
// silent: false,
testRegex: "/(tests|src)/.*\\.(test|spec)\\.[jt]sx?$",
/** for circle ci free plan */
testTimeout: 10000,
maxWorkers: 1,
maxConcurrency: 1,
globals: {
"ts-jest": {
}
},
transform: {
"^.+\\.tsx?$": "ts-jest"
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
setupFilesAfterEnv: ["<rootDir>/setup.ts"]
}
Example #4
Source File: jest.config.ts From react-datasheet-grid with MIT License | 6 votes |
config: Config.InitialOptions = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['./dist'],
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleNameMapper: {
'\\.css$': '<rootDir>/tests/helpers/styleMock.ts',
},
}
Example #5
Source File: jest.config.ts From copy-image-clipboard with MIT License | 6 votes |
config: Config.InitialOptions = {
clearMocks: true,
testTimeout: 30000,
collectCoverage: true,
coverageProvider: 'v8',
roots: ['<rootDir>/src'],
testEnvironment: 'jsdom',
coverageDirectory: 'coverage',
setupFiles: ['<rootDir>/setupTests.ts'],
}
Example #6
Source File: jest.config.ts From express-zod-api with MIT License | 6 votes |
config: Config.InitialOptions = {
preset: "ts-jest",
testEnvironment: "node",
verbose: true,
forceExit: true,
collectCoverage: true,
collectCoverageFrom: ["src/**"],
coverageReporters: ["json-summary", "text", "html", "lcov"],
testTimeout: 10000,
}
Example #7
Source File: jest.config.ts From strapi-plugin-comments with MIT License | 6 votes |
config: Config.InitialOptions = {
name: "Unit test",
testMatch: ["**/__tests__/?(*.)+(spec|test).ts"],
transform: {
...tsjPreset.transform,
},
preset: "ts-jest",
coverageDirectory: "./coverage/",
collectCoverage: true,
globals: {
"ts-jest": {
diagnostics: {
warnOnly: true,
},
},
},
}
Example #8
Source File: jest.config.ts From alauda-ui with MIT License | 6 votes |
config: Config.InitialOptions = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testMatch: ['<rootDir>/src/**/+(*.)+(spec|test).+(ts|js)?(x)'],
coverageReporters: ['text', 'html'],
coverageDirectory: '<rootDir>/coverage',
modulePathIgnorePatterns: [
'<rootDir>/release',
'<rootDir>/dist',
'<rootDir>/stories',
],
coveragePathIgnorePatterns: [
'<rootDir>/release',
'<rootDir>/dist',
'<rootDir>/stories',
'(\\w*/)*(\\w|\\.)+\\.html',
'(\\w*/)*index\\.ts',
'/node_modules/',
],
}
Example #9
Source File: runJest.d.ts From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution | 6 votes |
export default function runJest({ contexts, globalConfig, outputStream, testWatcher, jestHooks, startRun, changedFilesPromise, onComplete, failedTestsCache, filter, }: {
globalConfig: Config.GlobalConfig;
contexts: Array<Context>;
outputStream: NodeJS.WriteStream;
testWatcher: TestWatcher;
jestHooks?: JestHookEmitter;
startRun: (globalConfig: Config.GlobalConfig) => void;
changedFilesPromise?: ChangedFilesPromise;
onComplete: (testResults: AggregatedResult) => void;
failedTestsCache?: FailedTestsCache;
filter?: Filter;
}): Promise<void>;
Example #10
Source File: index.ts From garment with MIT License | 5 votes |
export async function getConfig(ctx: Context<JestRunnerOptions>) {
const batch = [...ctx.batch()];
const projsByConfig: {
[key: string]: Batch<JestRunnerOptions>[];
} = {};
batch.forEach(item => {
const { configFile } = item.options;
if (!projsByConfig[configFile]) {
projsByConfig[configFile] = [];
}
projsByConfig[configFile].push(item);
});
const projsKeys = Object.keys(projsByConfig);
const isMultipleConfigs = projsKeys.length > 1;
const jestConfig: Partial<Config.DefaultOptions> = {
rootDir: ctx.workspace.cwd,
projects: []
};
const configEntries = Object.entries(projsByConfig).map(
([configPath, items]) =>
[
configPath,
require(configPath) as Partial<
Config.DefaultOptions & Config.ProjectConfig
>,
items
] as const
);
const hasCollectCoverage = configEntries.some(([, config]) =>
Boolean(config.collectCoverage)
);
for (const [configPath, projectConfig, items] of configEntries) {
const rootDir = projectConfig.rootDir || Path.dirname(configPath);
const roots = items.map(
item => '<rootDir>/' + Path.relative(rootDir, item.project.fullPath)
);
projectConfig.rootDir = rootDir;
projectConfig.roots = roots;
if (isMultipleConfigs) {
if (projectConfig.collectCoverage) {
delete projectConfig.collectCoverage;
} else if (hasCollectCoverage) {
projectConfig.coveragePathIgnorePatterns = roots;
}
}
if (isMultipleConfigs && jestConfig.projects) {
jestConfig.projects.push(projectConfig as Config.ProjectConfig);
} else {
Object.assign(jestConfig, projectConfig);
}
}
if (hasCollectCoverage) {
jestConfig.collectCoverage = true;
}
return jestConfig;
}
Example #11
Source File: jest.config.ts From fuels-ts with Apache License 2.0 | 5 votes |
config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFiles: ['./jest.env.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
modulePathIgnorePatterns: ['/dist/'],
collectCoverageFrom: ['packages/**/*.[jt]s', '!**/node_modules/**', '!**/dist/**'],
}
Example #12
Source File: jest.config.ts From moment-guess with MIT License | 5 votes |
config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
}
Example #13
Source File: FailedTestsCache.d.ts From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution | 5 votes |
updateConfig(globalConfig: Config.GlobalConfig): Config.GlobalConfig;