Skip to content

Instantly share code, notes, and snippets.

@rluvaton
Last active June 25, 2023 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rluvaton/2195d8ced64b4eec75eb5b1752c4a733 to your computer and use it in GitHub Desktop.
Save rluvaton/2195d8ced64b4eec75eb5b1752c4a733 to your computer and use it in GitHub Desktop.

❯ jest --coverage=true
  console.log
    test

      at log (index.js:12:21)

 PASS  ./index.test.js
  work
    ✓ 1 and 2 pass (11 ms)
    ✓ 1 pass 2 not (1 ms)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |       75 |     100 |     100 |                   
 index.js |     100 |       75 |     100 |     100 | 5                 
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.179 s, estimated 1 s

module.exports = {
run(user) {
const notifications = {sent: false, channels: {}};
if(user.sensitiveDepartment) {
notifications.channels.email = {
address: user.email
};
}
if(!user.permission) {
console.log(notifications.channels.email.address)
notifications.sent = true;
}
}
}
const {run} = require('./index');
describe('work', () => {
it('1 and 2 pass', () => {
run({sensitiveDepartment: true, permission: false, email: 'test'})
});
it('1 pass 2 not', () => {
run({sensitiveDepartment: true, permission: true})
});
});
module.exports = {
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageProvider: 'babel'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment