File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Flags: js-defer-import-eval --experimental-import-text
2+
3+ // Test that uses import.defer for a builtin module. Currently
4+ // defer importing of a synthetic module should be a no-op
5+ // in Node.js, so the test is mostly a smoke test that Node
6+ // doesn't crash.
7+
8+ import '../common/index.mjs' ;
9+ import * as assert from 'assert' ;
10+
11+ // Import the file system builtin module.
12+ import defer * as fs from 'node:fs' ;
13+
14+ // Check that the imported module contains some known properties.
15+ assert . notStrictEqual ( fs . constants , undefined ) ;
16+ assert . notStrictEqual ( fs . access , undefined ) ;
17+ assert . strictEqual ( typeof fs . access , 'function' ) ;
18+
19+ // Check that the builtin module also exports some
20+ // usable contructor functions.
21+ assert . strictEqual ( typeof fs . Stats , 'function' ) ;
22+ assert . strictEqual ( typeof new fs . Stats ( ) , 'object' ) ;
Original file line number Diff line number Diff line change 1+ // Flags: --js-defer-import-eval
2+
3+ // Test that uses import.defer for a JSON module. Currently
4+ // defer importing of a synthetic module should be a no-op
5+ // in Node.js, so the test is mostly a smoke test that Node
6+ // doesn't crash.
7+
8+ import '../common/index.mjs' ;
9+ import * as assert from 'assert' ;
10+
11+ import defer * as imported_json
12+ from '../fixtures/json-with-directory-name-module/module-stub.json'
13+ with { type : 'json' } ;
14+
15+ // Check that the imported object has the expected key/value.
16+ assert . strictEqual ( imported_json . default . rocko , 'artischocko' ) ;
Original file line number Diff line number Diff line change 1+ // Flags: --js-defer-import-eval --experimental-import-text
2+
3+ // Test that uses import.defer for a text module. Currently
4+ // defer importing of a synthetic module should be a no-op
5+ // in Node.js, so the test is mostly a smoke test that Node
6+ // doesn't crash.
7+
8+ import '../common/index.mjs' ;
9+ import * as assert from 'assert' ;
10+
11+ import defer * as imported_text
12+ from '../fixtures/file-to-read-without-bom.txt'
13+ with { type : 'text' } ;
14+
15+ const expected_text = 'abc\ndef\nghi\n' ;
16+
17+ // Check that the imported text has the expected value.
18+ assert . strictEqual ( imported_text . default , expected_text ) ;
You can’t perform that action at this time.
0 commit comments