Skip to content

Commit

Permalink
test: .js extension in import
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Jul 9, 2022
1 parent ad01f49 commit d63f905
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ test.suite('ts-node', (test) => {
expect(stdout).toBe('hello world\n');
});

test.suite('should support js extension', (test) => {
test('test', async () => {
const { err, stdout } = await exec(
[
CMD_TS_NODE_WITHOUT_PROJECT_FLAG,
'-pe "import { main } from \'./index\';main()"',
].join(' '),
{
cwd: join(TEST_DIR, 'import-with-js-extension'),
}
);
expect(err).toBe(null);
expect(stdout).toBe('hello world\n');
});
});

test.suite('should support cts when module = CommonJS', (test) => {
test.runIf(tsSupportsMtsCtsExtensions);
test('test', async (t) => {
Expand Down
1 change: 1 addition & 0 deletions tests/import-with-js-extension/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const helloWorld = 'hello world';
5 changes: 5 additions & 0 deletions tests/import-with-js-extension/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { helloWorld } from './foo.js';

export function main() {
console.log(helloWorld);
}

0 comments on commit d63f905

Please sign in to comment.