Skip to content

Commit ee3bb30

Browse files
committed
augmented tests to validate fix for tj#12: when the test/testtest.js file is pulled through babel the tests coded in there would fail due the code having been prettyfied by babel. The tests have been adjusted.
1 parent cc69d2b commit ee3bb30

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"test001": "node example.js",
2929
"test002": "./node_modules/.bin/babel test/test-babel.js --out-file test/test-babel-out.js --source-maps && node test/test-babel-out.js",
3030
"test003": "node test/testtest.js",
31-
"test004": "./node_modules/.bin/babel index.js --out-file index-babel-out.js --source-maps && node index-babel-out.js",
32-
"test": "npm run test001 && npm run test002 && npm run test003 && npm run test004 && npm run clean",
31+
"test004": "./node_modules/.bin/babel test/testtest.js --out-file test/testtest-babel-out.js --source-maps && node test/testtest-babel-out.js",
32+
"test005": "./node_modules/.bin/babel index.js --out-file index-babel-out.js --source-maps && node index-babel-out.js",
33+
"test": "npm run test001 && npm run test002 && npm run test003 && npm run test004 && npm run test005 && npm run clean",
3334
"clean": "rm **/*-babel-out.* && rm *-babel-out.*",
3435
"pub": "npm publish --access public"
3536
},

test/testtest.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ try {
1616

1717
// tests which serve as simple better-assert library unit tests:
1818
console.log("\n\n==================================\n\n## Unit Tests for the library ##\n\n");
19-
20-
assert(ex.message.indexOf("(a==b,`${a} should be ${b}`) 1 should be 2") >= 0);
19+
20+
assert(
21+
// this check will match when run directly in node (v8, v10, ...)
22+
ex.message.indexOf("(a==b,`${a} should be ${b}`) 1 should be 2") >= 0 ||
23+
// while this check will match when run via a babel transpile (which prettyfies the code)
24+
ex.message.indexOf("(a == b, `${a} should be ${b}`) 1 should be 2") >= 0);
2125
assert(ex.name.indexOf("AssertionError") === 0);
2226

2327
console.log("PASS OK");

0 commit comments

Comments
 (0)