Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: replacing common.fixturesDir in test-require-exceptions.js
Using common.fixtures module instead of common.fixturesDir based on task at Nodejs code and learn at Node.js Interactive 2017 in Vancouver.
  • Loading branch information
tejbirsingh committed Oct 6, 2017
commit cfa33c2b079f669f78ffff748b4980e43940114c
9 changes: 5 additions & 4 deletions test/parallel/test-require-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fixtures = require ('../common/fixtures');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter complained:

not ok 25 - /usr/home/iojs/build/workspace/node-test-linter/test/parallel/test-require-exceptions.js
  ---
  message: Unexpected space between function name and paren.
  severity: error
  data:
    line: 25
    column: 18
    ruleId: func-call-spacing
  ...

Can you remove the space after require? Thanks.


// 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 @@ -43,13 +44,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)));
}