-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #1488 * add regression test
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Misc regression tests go here if they do not have a better home | ||
|
||
import * as exp from 'expect'; | ||
import { join } from 'path'; | ||
import { createExec, createExecTester } from './exec-helpers'; | ||
import { | ||
CMD_TS_NODE_WITHOUT_PROJECT_FLAG, | ||
contextTsNodeUnderTest, | ||
TEST_DIR, | ||
} from './helpers'; | ||
import { test as _test } from './testlib'; | ||
|
||
const test = _test.context(contextTsNodeUnderTest); | ||
const exec = createExecTester({ | ||
exec: createExec({ | ||
cwd: TEST_DIR, | ||
}), | ||
}); | ||
|
||
test('#1488 regression test', async () => { | ||
// Scenario that caused the bug: | ||
// `allowJs` turned on | ||
// `skipIgnore` turned on so that ts-node tries to compile itself (not ideal but theoretically we should be ok with this) | ||
// Attempt to `require()` a `.js` file | ||
// `assertScriptCanLoadAsCJS` is triggered within `require()` | ||
// `./package.json` needs to be fetched into cache via `assertScriptCanLoadAsCJS` which caused a recursive `require()` call | ||
// Circular dependency warning is emitted by node | ||
|
||
const { stdout, stderr } = await exec({ | ||
exec: createExec({ | ||
cwd: join(TEST_DIR, '1488'), | ||
}), | ||
cmd: `${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} ./index.js`, | ||
}); | ||
|
||
// Assert that we do *not* get `Warning: Accessing non-existent property 'getOptionValue' of module exports inside circular dependency` | ||
exp(stdout).toBe('foo\n'); // prove that it ran | ||
exp(stderr).toBe(''); // prove that no warnings | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true | ||
}, | ||
"ts-node": { | ||
"skipIgnore": true | ||
} | ||
} |