Skip to content

Commit 2267841

Browse files
committed
feat: adding a unit test for nock mocking
1 parent 6622d99 commit 2267841

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

package-lock.json

+37-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"har-examples": "^3.1.1",
6363
"msw": "^2.0.2",
6464
"multer": "^1.4.5-lts.1",
65+
"nock": "^14.0.0",
6566
"prettier": "^3.0.3",
6667
"temp-dir": "^3.0.0",
6768
"tsup": "^8.0.1",

test/mocking/nock.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import harExamples from 'har-examples';
2+
import nock from 'nock';
3+
import { describe, it, expect } from 'vitest';
4+
5+
import fetchHAR from '../../src/index.js';
6+
7+
describe('#fetchHAR mocking (nock)', () => {
8+
it('should support mocking a request with `nock`', async () => {
9+
nock('https://httpbin.org').get('/get').reply(429);
10+
11+
const res = await fetchHAR(harExamples.short);
12+
expect(res.status).toBe(429);
13+
14+
nock.restore();
15+
});
16+
});

0 commit comments

Comments
 (0)