Skip to content
Permalink
Browse files

feat(testing): add collectCoverageFrom jest parameter (#2613)

  • Loading branch information
irega committed Aug 9, 2020
1 parent 62e84aa commit 370a70122789570f80290e6b3ef7683cf00d9b5a
Showing with 19 additions and 0 deletions.
  1. +3 −0 src/testing/jest/jest-config.ts
  2. +16 −0 src/testing/jest/test/jest-config.spec.ts
@@ -55,6 +55,9 @@ export function buildJestConfig(config: d.Config) {
if (isString(stencilConfigTesting.collectCoverage)) {
jestConfig.collectCoverage = stencilConfigTesting.collectCoverage;
}
if (Array.isArray(stencilConfigTesting.collectCoverageFrom)) {
jestConfig.collectCoverageFrom = stencilConfigTesting.collectCoverageFrom;
}
if (isString(stencilConfigTesting.coverageDirectory)) {
jestConfig.coverageDirectory = stencilConfigTesting.coverageDirectory;
}
@@ -132,4 +132,20 @@ describe('jest-config', () => {
const parsedConfig = JSON.parse(jestArgv.config) as d.JestConfig;
expect(parsedConfig.rootDir).toBe(rootDir);
});

it('set jestArgv config collectCoverageFrom', () => {
const rootDir = path.resolve('/');
const args = ['test'];
const config = mockConfig();
config.rootDir = rootDir;
config.flags = parseFlags(args, config.sys);
config.testing = {
collectCoverageFrom: ['**/*.+(ts|tsx)'],
};

const jestArgv = buildJestArgv(config);
const parsedConfig = JSON.parse(jestArgv.config) as d.JestConfig;
expect(parsedConfig.collectCoverageFrom).toHaveLength(1);
expect(parsedConfig.collectCoverageFrom[0]).toBe('**/*.+(ts|tsx)');
});
});

0 comments on commit 370a701

Please sign in to comment.
You can’t perform that action at this time.