Skip to content

Commit

Permalink
test: change common.fixturesDir to fixtures.path
Browse files Browse the repository at this point in the history
Use common.fixtures module instead of common.fixturesDir based on task
at Nodejs code and learn at Node.js Interactive 2017 in Vancouver.

PR-URL: #15860
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
tejbirsingh authored and MylesBorins committed Nov 28, 2017
1 parent 806f03e commit 8eb84d6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/parallel/test-require-exceptions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');

// A module with an error in it should throw
assert.throws(function() {
require(`${common.fixturesDir}/throws_error`);
require(fixtures.path('/throws_error'));
}, /^Error: blah$/);

// Requiring the same module again should throw as well
assert.throws(function() {
require(`${common.fixturesDir}/throws_error`);
require(fixtures.path('/throws_error'));
}, /^Error: blah$/);

// Requiring a module that does not exist should throw an
Expand All @@ -22,13 +23,13 @@ assertModuleNotFound('/module-require/not-found/trailingSlash');

function assertModuleNotFound(path) {
assert.throws(function() {
require(common.fixturesDir + path);
require(fixtures.path(path));
}, function(e) {
assert.strictEqual(e.code, 'MODULE_NOT_FOUND');
return true;
});
}

function assertExists(fixture) {
assert(common.fileExists(common.fixturesDir + fixture));
assert(common.fileExists(fixtures.path(fixture)));
}

0 comments on commit 8eb84d6

Please sign in to comment.