Skip to content

Commit 5e2445a

Browse files
committed
Test userland assert and Node.js core assert
1 parent fc589c5 commit 5e2445a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.travis.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ language: node_js
22
matrix:
33
include:
44
- node_js: 'stable'
5+
env: TASK=test
56
- node_js: 'node'
67
env: VERSION=v12.0.0-rc.1
8+
env: TASK=test
79
before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION
8-
script: npm test
10+
- node_js: 'stable'
11+
env: TASK=test-native
12+
- node_js: 'node'
13+
env: VERSION=v12.0.0-rc.1
14+
env: TASK=test-native
15+
before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION
16+
script: npm run $TASK
917
notifications:
1018
email:
1119
on_success: never

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
"homepage": "https://github.com/browserify/commonjs-assert",
88
"repository": "browserify/commonjs-assert",
99
"scripts": {
10-
"test": "node test.js"
10+
"test": "node test.js",
11+
"test-native": "cross-env TEST_NATIVE=true npm test"
1112
},
1213
"keywords": [
1314
"assert",
1415
"browser"
1516
],
1617
"devDependencies": {
18+
"cross-env": "^5.2.0",
1719
"glob": "^7.1.3",
20+
"proxyquire": "^2.1.0",
1821
"tape": "^4.10.1"
1922
}
2023
}

test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
const test = require('tape');
22
const glob = require('glob');
33
const path = require('path');
4+
const proxyquire = require('proxyquire');
5+
6+
const assert = require(process.env.TEST_NATIVE === 'true' ? 'assert' : '.');
47

58
const testPaths = glob.sync('test/**/test-assert*.js');
69

710
testPaths.forEach(testPath => {
811
test(testPath, t => {
912
t.doesNotThrow(() => {
10-
require(path.resolve(__dirname, testPath));
13+
proxyquire(path.resolve(__dirname, testPath), {assert});
1114
});
1215
t.end();
1316
});

0 commit comments

Comments
 (0)