| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -593,28 +593,25 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 593 | 593 | ` | |
| 594 | 594 | import {MessageChannel} from 'node:worker_threads'; | |
| 595 | 595 | import {register} from 'node:module'; | |
| 596 | + import {setTimeout} from 'node:timers/promises'; | ||
| 596 | 597 | const {port1, port2} = new MessageChannel(); | |
| 597 | 598 | port1.on('message', (msg) => { | |
| 598 | 599 | console.log('message', msg); | |
| 599 | 600 | }); | |
| 600 | 601 | const result = register( | |
| 601 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/hooks-initialize-port.mjs'))}, | ||
| 602 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize-port.mjs'))}, | ||
| 602 | 603 | {data: port2, transferList: [port2]}, | |
| 603 | 604 | ); | |
| 604 | 605 | console.log('register', result); | |
| 605 | 606 | ||
| 606 | 607 | await import('node:os'); | |
| 608 | + await setTimeout(99); // delay to limit flakiness | ||
| 607 | 609 | port1.close(); | |
| 608 | 610 | `, | |
| 609 | 611 | ]); | |
| 610 | 612 | ||
| 611 | - const lines = stdout.split('\n'); | ||
| 612 | - | ||
| 613 | - assert.strictEqual(lines[0], 'register ok'); | ||
| 614 | - assert.strictEqual(lines[1], 'message initialize'); | ||
| 615 | - assert.strictEqual(lines[2], 'message resolve node:os'); | ||
| 616 | - | ||
| 617 | 613 | assert.strictEqual(stderr, ''); | |
| 614 | + assert.deepStrictEqual(stdout.split('\n'), ['register ok', 'message initialize', 'message resolve node:os', '']); | ||
| 618 | 615 | ||
| 619 | 616 | assert.strictEqual(code, 0); | |
| 620 | 617 | assert.strictEqual(signal, null); | |
@@ -626,26 +623,23 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 626 | 623 | '--input-type=commonjs', | |
| 627 | 624 | '--eval', | |
| 628 | 625 | ` | |
| 626 | + 'use strict'; | ||
| 629 | 627 | const {register} = require('node:module'); | |
| 630 | 628 | register( | |
| 631 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/hooks-initialize.mjs'))}, | ||
| 629 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'))}, | ||
| 632 | 630 | ); | |
| 633 | 631 | register( | |
| 634 | - ${JSON.stringify(fixtures.fileURL('/es-module-loaders/loader-load-foo-or-42.mjs'))}, | ||
| 632 | + ${JSON.stringify(fixtures.fileURL('es-module-loaders/loader-load-foo-or-42.mjs'))}, | ||
| 635 | 633 | ); | |
| 636 | 634 | ||
| 637 | 635 | import('node:os').then((result) => { | |
| 638 | - console.log(result.default); | ||
| 636 | + console.log(JSON.stringify(result)); | ||
| 639 | 637 | }); | |
| 640 | 638 | `, | |
| 641 | 639 | ]); | |
| 642 | 640 | ||
| 643 | - const lines = stdout.split('\n'); | ||
| 644 | - | ||
| 645 | - assert.strictEqual(lines[0], 'hooks initialize 1'); | ||
| 646 | - assert.strictEqual(lines[1], 'foo'); | ||
| 647 | - | ||
| 648 | 641 | assert.strictEqual(stderr, ''); | |
| 642 | + assert.deepStrictEqual(stdout.split('\n').sort(), ['hooks initialize 1', '{"default":"foo"}', ''].sort()); | ||
| 649 | 643 | ||
| 650 | 644 | assert.strictEqual(code, 0); | |
| 651 | 645 | assert.strictEqual(signal, null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments