Skip to content

Commit

Permalink
test: Always collect coverage
Browse files Browse the repository at this point in the history
But only set the threshold when running unit tests specifically.
This way coverage for single classes can easily be tested.
  • Loading branch information
joachimvh committed Jan 18, 2021
1 parent a46cd2b commit af88e13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
9 changes: 1 addition & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ module.exports = {
],
testEnvironment: 'node',
setupFilesAfterEnv: [ 'jest-rdf', '<rootDir>/test/util/SetupTests.ts' ],
collectCoverage: true,
coveragePathIgnorePatterns: [
'/dist/',
'/node_modules/',
'/test/',
],
coverageThreshold: {
'./src': {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
// Slower machines had problems calling the WebSocket integration callbacks on time
testTimeout: 10000,
};
13 changes: 13 additions & 0 deletions jest.coverage.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const jestConfig = require('./jest.config');

module.exports = {
...jestConfig,
coverageThreshold: {
'./src': {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"test:deploy": "test/deploy/validate-package.sh",
"test:ts": "tsc -p test --noEmit",
"test:integration": "jest test/integration",
"test:unit": "jest --collectCoverage test/unit",
"test:unit": "jest --config=./jest.coverage.config.js test/unit",
"test:watch": "jest --watch test/unit",
"validate": "componentsjs-compile-config urn:solid-server:default:Initializer -c config/config-default.json -f > /dev/null",
"version": "manual-git-changelog onversion",
Expand Down
4 changes: 3 additions & 1 deletion test/unit/init/CliRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ describe('CliRunner', (): void => {

it('exits with output to stderr when instantiation fails.', async(): Promise<void> => {
manager.instantiate.mockRejectedValueOnce(new Error('Fatal'));
new CliRunner().run();
new CliRunner().run({
argv: [ 'node', 'script' ],
});
await new Promise((resolve): any => setImmediate(resolve));

expect(write).toHaveBeenCalledTimes(2);
Expand Down

0 comments on commit af88e13

Please sign in to comment.