-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting "TypeError: Path must be a string. Received undefined" preventing me from upgrading to Jest v24 in some repos #7857
Comments
To add more context to this issue, I've been able to circumvent this problem currently by doing the following in each file that shows this issue: /* eslint-disable no-console */
const originalLog = console.log;
describe('suite', () => {
beforeAll(() => {
// TODO: Remove this once jest resolves https://github.com/facebook/jest/issues/7857
console.log = jest.fn((input) => {
process.stdout.write(`${input} \n`);
});
});
afterEach(() => {
console.log = originalLog;
/* eslint-enable */
}); I'm still not sure why this is happening though |
Please put together a repository we can pull down and check. If just using Jest 24 broke, we'd be getting a lot more reports π Do you have a custom transformer? #7844 will not help - the code basically identical. |
@SimenB I will work on that, As for the transformer I have
And the version in use is |
Cool, that shouldn't be a problem. Looking forward to the repo! |
@SimenB Here is my example repo where I was able to reproduce the issue https://github.com/Aghassi/oclif-jest-demo-failure |
Here is the output I got locally
|
This is happening because you set @SimenB is this supposed to be a supported option? It's not in the docs or in |
Caused by #7742 adding |
the same question with you @Aghassi |
Yes I guess the question is is |
IMO it just makes things confusing if |
@jeysal that's fair. I can't think of anything off hand where I want the working directory to be different. I guess even if we are using it in a CLI (which we are), we could do a |
I added mock Object.defineProperty(window, 'console', {
writable: true,
value: {
debug: () => {},
info: () => {},
error: () => {},
log: () => {},
}
}); |
The issue shown by the repro should be fixed in the next release. I still suspect your internal repo might have another problem though based on what you said in the PR. |
@jeysal hopefully not, but if that's the case I will have less trouble pin pointing it now that this is resolved π . Looking forward to the next version! |
Just to post back here to close this issue from my end. One of the other reasons I was seeing this issue was that someone on our team has done |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
π Bug Report
I have a number of repos in our enterprise setup that are running into the following error:
As far as I can tell, the trend seems to be related to when something in the test needs to output via the
console
, but a mock may be involved that either spies something related to a console log, or spies the console itself. This doesn't happen with all tests, only a few. And when running the tests one off, I get the same error, but with a stack trace that is more defined than the above.An example of one of the failing tests
It's possible this is fixed by https://github.com/facebook/jest/pull/7844/files, @SimenB maybe you can let me know? If so, I can wait till the next minor to validate.
EDIT: Doing some more digging it seems the config context is getting lost. When I run
console.log
on this line in my node_moduleshttps://github.com/facebook/jest/blob/b49075ede2ec0b26bc626e25c5d383df31770413/packages/jest-runner/src/index.js#L82
I get
cwd
isundefined
. When I runjest --showConfig
, I don't see thatcwd
is defined.To Reproduce
Steps to reproduce the behavior:
Expected behavior
All tests should pass
Link to repl or repo (highly encouraged)
I can't do this because the repl uses v22 of Jest
Please provide either a repl.it demo or a minimal repository on GitHub.
Issues without a reproduction link are likely to stall.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: