Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Cannot read property 'testPath' of undefined - Jest 26 #30

Open
pietrofxq opened this issue Apr 23, 2021 · 5 comments
Open

Cannot read property 'testPath' of undefined - Jest 26 #30

pietrofxq opened this issue Apr 23, 2021 · 5 comments

Comments

@pietrofxq
Copy link

pietrofxq commented Apr 23, 2021

this package does not work with the last version of jest. This is the problematic code:

function getDefaultRecordingDir() {
    const testPath = global.jasmine.testPath;
    return path_1.default.relative(process.cwd(), `${path_1.default.dirname(testPath)}/__recordings__`);
}

Seems like a quick fix but not sure what is the current best way to get testPath

@palmerj3
Copy link

Thanks for reporting!

I did a little digging into this.
This only occurs if you use the jest-circus test runner. If you use the default test runner or explicitly set jest-jasmine2 as the test runner it works fine with the latest version of jest.

I think I have a way to make this work with jest-circus in the latest jest version but it would require changing where the recordings are actually stored, possibly. I'm going to sync with a few others on this next week and revisit.

@pietrofxq
Copy link
Author

Thanks @palmerj3, since my project is on create-react-app, it would be very difficult to change the runner since I would need to configure jest from scratch

@pietrofxq
Copy link
Author

@palmerj3 I see that setup-polly-jest supports jest-circus, maybe updating this dependency would help?

@palmerj3
Copy link

Yeah I saw that too. Locally when I updated setup-polly-jest to the latest version and removed the block of code you referenced above I still saw some other errors that get triggered. So it will require a bit more thought.

That's why I wanted to involve some more colleagues into this.

@mits87
Copy link

mits87 commented Aug 17, 2021

The same issue, any progress with that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants