From a7275f6e2bf7e5e2e0c192ed1e7e86285b8b77a5 Mon Sep 17 00:00:00 2001 From: Kevin Grandon Date: Wed, 26 Sep 2018 10:01:37 -0700 Subject: [PATCH 1/2] Add assertion for istanbul ignore file --- test/cli/test.js | 5 +++++ test/fixtures/test-jest-app/src/istanbul-ignore-coverage.js | 4 ++++ test/fixtures/test-jest-app/src/main.js | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/test-jest-app/src/istanbul-ignore-coverage.js diff --git a/test/cli/test.js b/test/cli/test.js index 4dabd937..b9870d25 100644 --- a/test/cli/test.js +++ b/test/cli/test.js @@ -224,7 +224,12 @@ test('`fusion test` coverage', async t => { // Look for something like coverage t.ok(response.stdout.includes('Uncovered Line #s')); + // This file is outside of src and should not be included in coverage t.ok(!response.stdout.includes('should-not-count-for-coverage.js')); + + // This file instruments the istanbul ignore annotation and should not be included in coverage + t.ok(!response.stdout.includes('istanbul-ignore-coverage.js')); + t.end(); }); diff --git a/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.js b/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.js new file mode 100644 index 00000000..8760ab04 --- /dev/null +++ b/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.js @@ -0,0 +1,4 @@ +/* istanbul ignore file */ +// @flow + +export default function() {} diff --git a/test/fixtures/test-jest-app/src/main.js b/test/fixtures/test-jest-app/src/main.js index f94cdac9..fd9c177c 100644 --- a/test/fixtures/test-jest-app/src/main.js +++ b/test/fixtures/test-jest-app/src/main.js @@ -1,5 +1,8 @@ +// @flow import {foo} from './foo.js'; +import noop from './istanbul-ignore-coverage'; -export default function () { +export default function() { + noop(); return foo(); } From 7de4fa016db82b9e3d2fa904c6b4f5d80b6ceed0 Mon Sep 17 00:00:00 2001 From: Kevin Grandon Date: Wed, 26 Sep 2018 13:46:27 -0700 Subject: [PATCH 2/2] Add failing test case --- test/cli/test.js | 3 ++- .../test-jest-app/src/istanbul-ignore-coverage.flow.js | 8 ++++++++ test/fixtures/test-jest-app/src/main.js | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/test-jest-app/src/istanbul-ignore-coverage.flow.js diff --git a/test/cli/test.js b/test/cli/test.js index b9870d25..14b6dc4d 100644 --- a/test/cli/test.js +++ b/test/cli/test.js @@ -227,8 +227,9 @@ test('`fusion test` coverage', async t => { // This file is outside of src and should not be included in coverage t.ok(!response.stdout.includes('should-not-count-for-coverage.js')); - // This file instruments the istanbul ignore annotation and should not be included in coverage + // These files instruments the istanbul ignore annotation and should not be included in coverage t.ok(!response.stdout.includes('istanbul-ignore-coverage.js')); + t.ok(!response.stdout.includes('istanbul-ignore-coverage.flow.js')); t.end(); }); diff --git a/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.flow.js b/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.flow.js new file mode 100644 index 00000000..aacb0e89 --- /dev/null +++ b/test/fixtures/test-jest-app/src/istanbul-ignore-coverage.flow.js @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +// @generated +// @flow +// This file should not be present in coverage due to the istanbul ignore file annotation. +// The `import *` syntax is required for this test case. +import * as FusionCore from 'fusion-core'; + +export type Something = FusionCore.Context; diff --git a/test/fixtures/test-jest-app/src/main.js b/test/fixtures/test-jest-app/src/main.js index fd9c177c..cfe7dde6 100644 --- a/test/fixtures/test-jest-app/src/main.js +++ b/test/fixtures/test-jest-app/src/main.js @@ -1,6 +1,7 @@ // @flow import {foo} from './foo.js'; -import noop from './istanbul-ignore-coverage'; +import noop from './istanbul-ignore-coverage.js'; +import type {Something} from './istanbul-ignore-coverage.flow.js'; export default function() { noop();