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 <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • 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.