diff --git a/.travis.yml b/.travis.yml index 5f36761..c021890 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,16 @@ language: node_js matrix: include: - node_js: 'stable' + env: TASK=test - node_js: 'node' - env: VERSION=v12.0.0-rc.1 + env: TASK=test VERSION=v12.0.0-rc.1 before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION -script: npm test + - node_js: 'stable' + env: TASK=test-native + - node_js: 'node' + env: TASK=test-native VERSION=v12.0.0-rc.1 + before_install: NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install $VERSION +script: npm run $TASK notifications: email: on_success: never diff --git a/package.json b/package.json index 88bae63..c97182a 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/browserify/commonjs-assert", "repository": "browserify/commonjs-assert", "scripts": { - "test": "node test.js" + "test": "node test.js", + "test-native": "cross-env TEST_NATIVE=true npm test" }, "keywords": [ "assert", "browser" ], "devDependencies": { + "cross-env": "^5.2.0", "glob": "^7.1.3", + "proxyquire": "^2.1.0", "tape": "^4.10.1" } } diff --git a/test.js b/test.js index 74959b0..8d29b4d 100644 --- a/test.js +++ b/test.js @@ -1,13 +1,16 @@ const test = require('tape'); const glob = require('glob'); const path = require('path'); +const proxyquire = require('proxyquire'); + +const assert = require(process.env.TEST_NATIVE === 'true' ? 'assert' : '.'); const testPaths = glob.sync('test/**/test-assert*.js'); testPaths.forEach(testPath => { test(testPath, t => { t.doesNotThrow(() => { - require(path.resolve(__dirname, testPath)); + proxyquire(path.resolve(__dirname, testPath), {assert}); }); t.end(); });