Skip to content

Commit b326cdd

Browse files
committed
Test usage with babel-plugin-istanbul
1 parent f81ac66 commit b326cdd

5 files changed

Lines changed: 87 additions & 1 deletion

File tree

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ module.exports = {
2222
jest: true,
2323
},
2424
},
25+
{
26+
files: ['fixtures/**/*.js'],
27+
parserOptions: {
28+
sourceType: 'module',
29+
},
30+
},
2531
],
2632
};

__tests__/index-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,13 @@ describe('when used with typescript', () => {
422422
expect(actual).toEqual(`Ember.addObserver();`);
423423
});
424424
});
425+
426+
describe('when used with babel-plugin-istanbul', () => {
427+
it('throws an exception', () => {
428+
expect(() => {
429+
babel7.transformFileSync('./fixtures/istanbul-should-cover.js', {
430+
plugins: [[require('babel-plugin-istanbul')], Plugin],
431+
});
432+
}).toThrow(/Container is falsy/i);
433+
});
434+
});

fixtures/istanbul-should-cover.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-disable */
2+
3+
import EmberObject from '@ember/object';
4+
import Evented from '@ember/object/evented';
5+
6+
export default class TestObject extends EmberObject.extend(Evented) {
7+
foo() {
8+
console.log('foo');
9+
}
10+
};
11+
12+
const instance = TestObject.create();
13+
instance.foo();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@babel/plugin-transform-typescript": "^7.12.1",
3636
"@babel/preset-env": "^7.12.1",
3737
"babel-core": "^6.25.0",
38+
"babel-plugin-istanbul": "^6.0.0",
3839
"eslint": "^7.12.1",
3940
"eslint-config-prettier": "^6.15.0",
4041
"eslint-plugin-node": "^11.1.0",

yarn.lock

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.1.tgz#d7386a689aa0ddf06255005b4b991988021101a0"
1515
integrity sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ==
1616

17-
"@babel/core@^7.1.0", "@babel/core@^7.12.3":
17+
"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.5":
1818
version "7.12.3"
1919
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.3.tgz#1b436884e1e3bff6fb1328dc02b208759de92ad8"
2020
integrity sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g==
@@ -877,6 +877,22 @@
877877
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
878878
integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==
879879

880+
"@istanbuljs/load-nyc-config@^1.0.0":
881+
version "1.1.0"
882+
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
883+
integrity sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==
884+
dependencies:
885+
camelcase "^5.3.1"
886+
find-up "^4.1.0"
887+
get-package-type "^0.1.0"
888+
js-yaml "^3.13.1"
889+
resolve-from "^5.0.0"
890+
891+
"@istanbuljs/schema@^0.1.2":
892+
version "0.1.2"
893+
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
894+
integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==
895+
880896
"@jest/console@^24.7.1", "@jest/console@^24.9.0":
881897
version "24.9.0"
882898
resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.9.0.tgz#79b1bc06fb74a8cfb01cbdedf945584b1b9707f0"
@@ -1699,6 +1715,17 @@ babel-plugin-istanbul@^5.1.0:
16991715
istanbul-lib-instrument "^3.3.0"
17001716
test-exclude "^5.2.3"
17011717

1718+
babel-plugin-istanbul@^6.0.0:
1719+
version "6.0.0"
1720+
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.0.0.tgz#e159ccdc9af95e0b570c75b4573b7c34d671d765"
1721+
integrity sha512-AF55rZXpe7trmEylbaE1Gv54wn6rwU03aptvRoVIGP8YykoSxqdVLV1TfwflBCE/QtHmqtP8SWlTENqbK8GCSQ==
1722+
dependencies:
1723+
"@babel/helper-plugin-utils" "^7.0.0"
1724+
"@istanbuljs/load-nyc-config" "^1.0.0"
1725+
"@istanbuljs/schema" "^0.1.2"
1726+
istanbul-lib-instrument "^4.0.0"
1727+
test-exclude "^6.0.0"
1728+
17021729
babel-plugin-jest-hoist@^24.9.0:
17031730
version "24.9.0"
17041731
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.9.0.tgz#4f837091eb407e01447c8843cbec546d0002d756"
@@ -3109,6 +3136,11 @@ get-caller-file@^2.0.1:
31093136
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
31103137
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
31113138

3139+
get-package-type@^0.1.0:
3140+
version "0.1.0"
3141+
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
3142+
integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==
3143+
31123144
get-stdin@^6.0.0:
31133145
version "6.0.0"
31143146
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
@@ -3848,6 +3880,11 @@ istanbul-lib-coverage@^2.0.2, istanbul-lib-coverage@^2.0.5:
38483880
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz#675f0ab69503fad4b1d849f736baaca803344f49"
38493881
integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==
38503882

3883+
istanbul-lib-coverage@^3.0.0:
3884+
version "3.0.0"
3885+
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec"
3886+
integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==
3887+
38513888
istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.3.0:
38523889
version "3.3.0"
38533890
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz#a5f63d91f0bbc0c3e479ef4c5de027335ec6d630"
@@ -3861,6 +3898,16 @@ istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.3.0:
38613898
istanbul-lib-coverage "^2.0.5"
38623899
semver "^6.0.0"
38633900

3901+
istanbul-lib-instrument@^4.0.0:
3902+
version "4.0.3"
3903+
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d"
3904+
integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==
3905+
dependencies:
3906+
"@babel/core" "^7.7.5"
3907+
"@istanbuljs/schema" "^0.1.2"
3908+
istanbul-lib-coverage "^3.0.0"
3909+
semver "^6.3.0"
3910+
38643911
istanbul-lib-report@^2.0.4:
38653912
version "2.0.8"
38663913
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz#5a8113cd746d43c4889eba36ab10e7d50c9b4f33"
@@ -6418,6 +6465,15 @@ test-exclude@^5.2.3:
64186465
read-pkg-up "^4.0.0"
64196466
require-main-filename "^2.0.0"
64206467

6468+
test-exclude@^6.0.0:
6469+
version "6.0.0"
6470+
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"
6471+
integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==
6472+
dependencies:
6473+
"@istanbuljs/schema" "^0.1.2"
6474+
glob "^7.1.4"
6475+
minimatch "^3.0.4"
6476+
64216477
text-table@^0.2.0:
64226478
version "0.2.0"
64236479
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"

0 commit comments

Comments
 (0)