Skip to content

Commit

Permalink
test: add nock
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Jul 25, 2024
1 parent 7e97288 commit 13db682
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"extension": [
"ts"
],
"file": [
"test/setup.ts"
],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"test:mocha:dev:update": "PRUNE_OLD_SNAPSHOTS=1 UPDATE_EXISTING_SNAPSHOTS=1 npm run test:mocha:dev",
"test:mocha:dev:updateNoPrune": "UPDATE_EXISTING_SNAPSHOTS=1 npm run test:mocha:dev",
"test:e2e": "npm run test:e2e:cases && npm run test:e2e:docker && npm run test:e2e:run",
"test:e2e:docker": "docker build -t globalping-probe-e2e . && docker build --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 -t globalping-api-e2e test/e2e/globalping",
"test:e2e:cases": "git clone https://github.com/jsdelivr/globalping.git test/e2e/globalping; cd test/e2e/globalping && git add . && git reset --hard && git pull --force && npm install; cd ../../../; for f in config/e2e-api-*; do cp \"$f\" \"test/e2e/globalping/config/${f#config/e2e-api-}\"; done;",
"test:e2e:docker": "docker build -t globalping-probe-e2e . && docker build --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 -t globalping-api-e2e test/e2e/globalping",
"test:e2e:run": "cd test/e2e/globalping; TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha --config ./.mocharc.e2e.cjs; cd ../../../"
},
"lint-staged": {
Expand Down
5 changes: 5 additions & 0 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import nock from 'nock';

before(async () => {
nock.disableNetConnect();
});
6 changes: 5 additions & 1 deletion wallaby.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function wallaby () {
'test/plugins/**/*',
'test/utils.ts',
'test/hooks.ts',
'test/setup.ts',
'test/snapshots/**/*.json',
'package.json',
],
Expand All @@ -20,7 +21,10 @@ export default function wallaby () {
],
setup (w) {
const path = require('path');
w.testFramework.addFile(path.resolve(process.cwd(), 'test/hooks.js'));
w.testFramework.files.unshift(path.resolve(process.cwd(), 'test/hooks.js'));
w.testFramework.files.unshift(path.resolve(process.cwd(), 'test/setup.js'));
const mocha = w.testFramework;
mocha.timeout(5000);
},
env: {
type: 'node',
Expand Down

0 comments on commit 13db682

Please sign in to comment.