-
Notifications
You must be signed in to change notification settings - Fork 8
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
Disable Nock for a spec or a list of specs #7
Comments
I'm not 100% sure that I understand your problem. But my guess is that the interceptors from your HTTP test files are intercepting Socket.IO requests. This would be because One way you can counteract this would be to run each file in a separate node process. Jest does this by default for example. |
I'm going to close this issue, let me know if you have further questions |
@edorivai that is not entirely true. I have a test suite (let's call it "public") where one suite makes a request to the internet, and another that gets nocked (let's call it "walled"). If the "walled" suite is executed before the "public", the latter fails with:
This is due to how Running them in "public" > "walled" sequence with My fix was to call import { setupRecorder } from 'nock-record'
import * as nock from 'nock'
// ...
const record = setupRecorder()
describe('sample', () => {
test('should retrieve user info', async () => {
const { completeRecording, assertScopesFinished } = await record(
'github-edorivai'
)
const result = await getGithubProfile('edorivai')
completeRecording()
assertScopesFinished()
expect(result).toMatchSnapshot()
})
afterAll(() => {
nock.restore()
})
}) Hope that helps. |
I am trying to test Socket.IO functions in a spec file as well as other files containing HTTP requests using nock-record. The Socket.IO tests fail when run along with the tests but succeed when run alone (targeting one spec file).
Is there a way to disable them for a certain spec files?
The text was updated successfully, but these errors were encountered: