| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 385f24c commit 26f0166
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -541,28 +541,25 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 541 | 541 | ` | |
| 542 | 542 | import {MessageChannel} from 'node:worker_threads'; | |
| 543 | 543 | import {register} from 'node:module'; | |
| 544 | + import {setTimeout} from 'node:timers/promises'; | ||
| 544 | 545 | const {port1, port2} = new MessageChannel(); | |
| 545 | 546 | port1.on('message', (msg) => { | |
| 546 | 547 | console.log('message', msg); | |
| 547 | 548 | }); | |
| 548 | 549 | const result = register( | |
| 549 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/hooks-initialize-port.mjs'))}, | ||
| 550 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize-port.mjs'))}, | ||
| 550 | 551 | {data: port2, transferList: [port2]}, | |
| 551 | 552 | ); | |
| 552 | 553 | console.log('register', result); | |
| 553 | 554 | ||
| 554 | 555 | await import('node:os'); | |
| 556 | + await setTimeout(99); // delay to limit flakiness | ||
| 555 | 557 | port1.close(); | |
| 556 | 558 | `, | |
| 557 | 559 | ]); | |
| 558 | 560 | ||
| 559 | - const lines = stdout.split('\n'); | ||
| 560 | - | ||
| 561 | - assert.strictEqual(lines[0], 'register ok'); | ||
| 562 | - assert.strictEqual(lines[1], 'message initialize'); | ||
| 563 | - assert.strictEqual(lines[2], 'message resolve node:os'); | ||
| 564 | - | ||
| 565 | 561 | assert.strictEqual(stderr, ''); | |
| 562 | + assert.deepStrictEqual(stdout.split('\n'), ['register ok', 'message initialize', 'message resolve node:os', '']); | ||
| 566 | 563 | ||
| 567 | 564 | assert.strictEqual(code, 0); | |
| 568 | 565 | assert.strictEqual(signal, null); | |
@@ -574,26 +571,23 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 574 | 571 | '--input-type=commonjs', | |
| 575 | 572 | '--eval', | |
| 576 | 573 | ` | |
| 574 | + 'use strict'; | ||
| 577 | 575 | const {register} = require('node:module'); | |
| 578 | 576 | register( | |
| 579 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/hooks-initialize.mjs'))}, | ||
| 577 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'))}, | ||
| 580 | 578 | ); | |
| 581 | 579 | register( | |
| 582 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/loader-load-foo-or-42.mjs'))}, | ||
| 580 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/loader-load-foo-or-42.mjs'))}, | ||
| 583 | 581 | ); | |
| 584 | 582 | ||
| 585 | 583 | import('node:os').then((result) => { | |
| 586 | - console.log(result.default); | ||
| 584 | + console.log(JSON.stringify(result)); | ||
| 587 | 585 | }); | |
| 588 | 586 | `, | |
| 589 | 587 | ]); | |
| 590 | 588 | ||
| 591 | - const lines = stdout.split('\n'); | ||
| 592 | - | ||
| 593 | - assert.strictEqual(lines[0], 'hooks initialize 1'); | ||
| 594 | - assert.strictEqual(lines[1], 'foo'); | ||
| 595 | - | ||
| 596 | 589 | assert.strictEqual(stderr, ''); | |
| 590 | + assert.deepStrictEqual(stdout.split('\n').sort(), ['hooks initialize 1', '{"default":"foo"}', ''].sort()); | ||
| 597 | 591 | ||
| 598 | 592 | assert.strictEqual(code, 0); | |
| 599 | 593 | assert.strictEqual(signal, null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments