Skip to content

Commit 00dc6d5

Browse files
committed
Test userland assert and Node.js core assert
1 parent fc589c5 commit 00dc6d5

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.travis.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ language: node_js
22
matrix:
33
include:
44
- node_js: 'stable'
5+
env: TASK=test
56
- node_js: 'node'
6-
env: VERSION=v12.0.0-rc.1
7+
env: TASK=test VERSION=v12.0.0-rc.1
78
before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION
8-
script: npm test
9+
- node_js: 'stable'
10+
env: TASK=test-native
11+
- node_js: 'node'
12+
env: TASK=test-native VERSION=v12.0.0-rc.1
13+
before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION
14+
script: npm run $TASK
915
notifications:
1016
email:
1117
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)