From 5e2445a2f16be30d17d2cfb3bf96b31e5de3d3ef Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Wed, 17 Apr 2019 18:27:09 +0700 Subject: [PATCH] Test userland assert and Node.js core assert --- .travis.yml | 10 +++++++++- package.json | 5 ++++- test.js | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f36761..11bbda0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,18 @@ language: node_js matrix: include: - node_js: 'stable' + env: TASK=test - node_js: 'node' env: VERSION=v12.0.0-rc.1 + env: TASK=test 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: VERSION=v12.0.0-rc.1 + env: TASK=test-native + 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(); });