Skip to content

Commit

Permalink
Test coverage: add test case to confirm that moduleType overrides are…
Browse files Browse the repository at this point in the history
… applied for ts-node in loader mode
  • Loading branch information
jayaddison committed Jun 20, 2021
1 parent dcbd916 commit c9c443c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/index.spec.ts
Expand Up @@ -1888,5 +1888,12 @@ test.suite('ts-node', (test) => {
expect(stdout).to.contain('CommonJS');
});
}

test('moduleTypes can override module type to CJS in an ESM loader project', async () => {
const { err, stderr, stdout } = await exec(
`${cmd} ./module-types/test.esm.js`
);
expect(err).to.equal(null);
});
});
});
3 changes: 3 additions & 0 deletions tests/module-types/src/cjs-subdir/esm-exception/index.ts
@@ -0,0 +1,3 @@
export const cjs: boolean = true;

export const requireType = typeof require;
2 changes: 2 additions & 0 deletions tests/module-types/src/cjs-subdir/index.ts
@@ -1 +1,3 @@
export const cjs: boolean = true;

export const requireType = typeof require;
7 changes: 7 additions & 0 deletions tests/module-types/test.esm.js
@@ -0,0 +1,7 @@
import assert from 'assert';

import cjsSubdirCJS from './src/cjs-subdir';
import cjsSubdirESM from './src/cjs-subdir/esm-exception';

assert(cjsSubdirCJS.requireType === 'function');
assert(cjsSubdirESM.requireType === 'undefined');

0 comments on commit c9c443c

Please sign in to comment.