Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix assert messages in case of failure #21833

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
40 changes: 17 additions & 23 deletions test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ const backslash = /\\/g;

console.error('load test-module-loading.js');

// assert that this is the main module.
assert.strictEqual(require.main.id, '.', 'main module should have id of \'.\'');
assert.strictEqual(require.main, module, 'require.main should === module');
assert.strictEqual(process.mainModule, module,
'process.mainModule should === module');
assert.strictEqual(require.main.id, '.');
assert.strictEqual(require.main, module);
assert.strictEqual(process.mainModule, module);

// assert that it's *not* the main module in the required module.
require('../fixtures/not-main-module.js');

Expand Down Expand Up @@ -102,12 +101,9 @@ const d2 = require('../fixtures/b/d');
assert.notStrictEqual(threeFolder, three);
}

assert.strictEqual(require('../fixtures/packages/index').ok, 'ok',
'Failed loading package');
assert.strictEqual(require('../fixtures/packages/main').ok, 'ok',
'Failed loading package');
assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok',
'Failed loading package with index.js in main subdir');
assert.strictEqual(require('../fixtures/packages/index').ok, 'ok');
assert.strictEqual(require('../fixtures/packages/main').ok, 'ok');
assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok');

{
console.error('test cycles containing a .. path');
Expand Down Expand Up @@ -165,8 +161,7 @@ require.extensions['.test'] = function(module) {

assert.strictEqual(require('../fixtures/registerExt2').custom, 'passed');

assert.strictEqual(require('../fixtures/foo').foo, 'ok',
'require module with no extension');
assert.strictEqual(require('../fixtures/foo').foo, 'ok');

// Should not attempt to load a directory
try {
Expand All @@ -181,13 +176,12 @@ try {
console.error('load order');

const loadOrder = '../fixtures/module-load-order/';
const msg = 'Load order incorrect.';

require.extensions['.reg'] = require.extensions['.js'];
require.extensions['.reg2'] = require.extensions['.js'];

assert.strictEqual(require(`${loadOrder}file1`).file1, 'file1', msg);
assert.strictEqual(require(`${loadOrder}file2`).file2, 'file2.js', msg);
assert.strictEqual(require(`${loadOrder}file1`).file1, 'file1');
assert.strictEqual(require(`${loadOrder}file2`).file2, 'file2.js');
try {
require(`${loadOrder}file3`);
} catch (e) {
Expand All @@ -197,9 +191,10 @@ try {
else
assert.ok(/file3\.node/.test(e.message.replace(backslash, '/')));
}
assert.strictEqual(require(`${loadOrder}file4`).file4, 'file4.reg', msg);
assert.strictEqual(require(`${loadOrder}file5`).file5, 'file5.reg2', msg);
assert.strictEqual(require(`${loadOrder}file6`).file6, 'file6/index.js', msg);

assert.strictEqual(require(`${loadOrder}file4`).file4, 'file4.reg');
assert.strictEqual(require(`${loadOrder}file5`).file5, 'file5.reg2');
assert.strictEqual(require(`${loadOrder}file6`).file6, 'file6/index.js');
try {
require(`${loadOrder}file7`);
} catch (e) {
Expand All @@ -208,10 +203,9 @@ try {
else
assert.ok(/file7\/index\.node/.test(e.message.replace(backslash, '/')));
}
assert.strictEqual(require(`${loadOrder}file8`).file8, 'file8/index.reg',
msg);
assert.strictEqual(require(`${loadOrder}file9`).file9, 'file9/index.reg2',
msg);

assert.strictEqual(require(`${loadOrder}file8`).file8, 'file8/index.reg');
assert.strictEqual(require(`${loadOrder}file9`).file9, 'file9/index.reg2');
}

{
Expand Down