grafana/toolkit: update the way config is being passed to jest cli (#18115)

pull/18112/head^2
Dominik Prokop 6 years ago committed by GitHub
parent 88d9a3b440
commit 29c89de140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      packages/grafana-toolkit/src/cli/tasks/plugin/tests.ts
  2. 16
      packages/grafana-toolkit/src/config/jest.plugin.config.ts

@ -10,10 +10,15 @@ export interface PluginTestOptions {
export const testPlugin = useSpinner<PluginTestOptions>('Running tests', async ({ updateSnapshot, coverage }) => {
const testConfig = jestConfig();
testConfig.updateSnapshot = updateSnapshot;
testConfig.coverage = coverage;
const cliConfig = {
config: JSON.stringify(testConfig),
updateSnapshot,
coverage,
passWithNoTests: true,
};
const results = await jestCLI.runCLI(testConfig as any, [process.cwd()]);
// @ts-ignore
const results = await jestCLI.runCLI(cliConfig, [process.cwd()]);
if (results.results.numFailedTests > 0 || results.results.numFailedTestSuites > 0) {
throw new Error('Tests failed');

@ -1,7 +1,7 @@
import path = require('path');
import fs = require('fs');
const whitelistedJestConfigOverrides = ['snapshotSerializers'];
const whitelistedJestConfigOverrides = ['snapshotSerializers', 'moduleNameMapper'];
export const jestConfig = () => {
const jestConfigOverrides = require(path.resolve(process.cwd(), 'package.json')).jest;
@ -23,17 +23,21 @@ export const jestConfig = () => {
const defaultJestConfig = {
preset: 'ts-jest',
verbose: false,
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
moduleDirectories: ['node_modules', 'src'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
setupFiles,
globals: { 'ts-jest': { isolatedModules: true } },
coverageReporters: ['json-summary', 'text', 'lcov'],
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!**/node_modules/**', '!**/vendor/**'],
updateSnapshot: false,
passWithNoTests: true,
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}',
],
transformIgnorePatterns: [
'[/\\\\\\\\]node_modules[/\\\\\\\\].+\\\\.(js|jsx|ts|tsx)$',
'^.+\\\\.module\\\\.(css|sass|scss)$',
],
};
return {

Loading…
Cancel
Save