Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
test: exclude mock from coverage#59348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import {getData, sum} from './sum.js' | ||
| export const theModuleSum = (a, b) => sum(a,b) | ||
| export const theModuleGetData = () => getData() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // console.log('imported') | ||
| const data = { type: 'object' } | ||
| // console.log(data) | ||
| export const sum = (a, b) => a + b | ||
| export const getData = () => data |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { describe, it, mock } from 'node:test'; | ||
| describe('module test with mock', async () => { | ||
| mock.module('../coverage-with-mock/sum.js', { | ||
| namedExports: { | ||
| sum: (a, b) => 1, | ||
| getData: () => ({}), | ||
| }, | ||
| }); | ||
| const { theModuleSum, theModuleGetData } = await import('../coverage-with-mock/module.js'); | ||
| it('tests correct thing', (t) => { | ||
| t.assert.strictEqual(theModuleSum(1, 2), 1); | ||
| t.assert.deepStrictEqual(theModuleGetData(), {}); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| TAP version 13 | ||
| # Subtest: module test with mock | ||
| # Subtest: tests correct thing | ||
| ok 1 - tests correct thing | ||
| --- | ||
| duration_ms: * | ||
| type: 'test' | ||
| ... | ||
| 1..1 | ||
| ok 1 - module test with mock | ||
| --- | ||
| duration_ms: * | ||
| type: 'suite' | ||
| ... | ||
| 1..1 | ||
| # tests 1 | ||
| # suites 1 | ||
| # pass 1 | ||
| # fail 0 | ||
| # cancelled 0 | ||
| # skipped 0 | ||
| # todo 0 | ||
| # duration_ms * | ||
| # start of coverage report | ||
| # --------------------------------------------------------------------------- | ||
| # file | line % | branch % | funcs % | uncovered lines | ||
| # --------------------------------------------------------------------------- | ||
| # test | | | | | ||
| # fixtures | | | | | ||
| # test-runner | | | | | ||
| # coverage-with-mock | | | | | ||
| # module.js | 100.00 | 100.00 | 100.00 | | ||
| # output | | | | | ||
| # coverage-with-mock.mjs | 100.00 | 100.00 | 100.00 | | ||
| # --------------------------------------------------------------------------- | ||
| # all files | 100.00 | 100.00 | 100.00 | | ||
| # --------------------------------------------------------------------------- | ||
| # end of coverage report | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,11 +29,11 @@ ok 1 - foo | ||
| # fixtures | | | | | ||
| # test-runner | | | | | ||
| # coverage | | | | | ||
| # bar.mts | 0.00 | 100.00 | 100.00 | 1-3 | ||
| # bar.mts | 33.33 | 100.00 | 0.00 | 2-3 | ||
| # foo.mts | 100.00 | 100.00 | 100.00 | | ||
| # output | | | | | ||
| # typescript-coverage.mts | 100.00 | 100.00 | 100.00 | | ||
| # ---------------------------------------------------------------------------- | ||
| # all files | 85.29 | 100.00 | 85.71 | | ||
| # all files | 93.55 | 100.00 | 85.71 | | ||
Comment on lines
32
to
37
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since | ||
| # ---------------------------------------------------------------------------- | ||
| # end of coverage report | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.