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
Prev Previous commit
Next Next commit
test: previous test changed to assert.rejects style
  • Loading branch information
zhanzhenzhen committed Mar 28, 2018
commit 0b3bd333229308a6b3b5bf42974396be9c47d1ee
12 changes: 6 additions & 6 deletions test/es-module/test-esm-throw-undefined.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import common from '../common/index.js';
import assert from 'assert';

@TimothyGu TimothyGu Mar 27, 2018 •

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.

nit: add a common.crashOnUnhandledRejection(); line here, and remove the .then(common.mustCall()) later.

@zhanzhenzhen zhanzhenzhen Mar 28, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TimothyGu Thank you. As this is the first time I make a pull request I'm not very familiar with the these functions. You can add it later :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TimothyGu I added.

async function doTest() {
try {
await import('../fixtures/es-module-loaders/throw-undefined');
assert(false);
} catch (e) {
assert.strictEqual(e, undefined);
}
await assert.rejects(
async () => {
await import('../fixtures/es-module-loaders/throw-undefined');
},
(e) => e === undefined
);

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.

Nit:

await assert.rejects(
  import('../fixtures/es-module-loaders/throw-undefined'),
  (e) => e === undefined);

The extra arrow function doesn't seem needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just followed the example here:
https://github.com/nodejs/node/blob/master/doc/api/assert.md

You mean, the first parameter can be a promise (not a function)? I don't know, but I think mine is more formal :)

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.

Oh oops, never mind that.

}

doTest().then(common.mustCall());