mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
ci: Block all external network calls in tests (no-changelog) (#4930)
* setup nock to prevent tests from making any external requests * mock all calls to posthog sdk
This commit is contained in:
parent
2964458191
commit
d5b06ab3d6
|
@ -45,6 +45,7 @@
|
|||
"jest": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.3.1",
|
||||
"jest-mock": "^29.3.1",
|
||||
"nock": "^13.2.9",
|
||||
"node-fetch": "^2.6.7",
|
||||
"prettier": "^2.3.2",
|
||||
"rimraf": "^3.0.2",
|
||||
|
|
|
@ -4,6 +4,7 @@ module.exports = {
|
|||
testEnvironmentOptions: {
|
||||
url: 'http://localhost/',
|
||||
},
|
||||
globalSetup: '<rootDir>/test/setup.ts',
|
||||
globalTeardown: '<rootDir>/test/teardown.ts',
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
|
|
6
packages/cli/test/setup.ts
Normal file
6
packages/cli/test/setup.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import nock from 'nock';
|
||||
|
||||
export default async () => {
|
||||
nock.disableNetConnect();
|
||||
nock.enableNetConnect('127.0.0.1');
|
||||
};
|
|
@ -1,6 +1,8 @@
|
|||
import { Telemetry } from '@/telemetry';
|
||||
import config from '@/config';
|
||||
|
||||
jest.mock('posthog-node');
|
||||
|
||||
jest.spyOn(Telemetry.prototype as any, 'initRudderStack').mockImplementation(() => {
|
||||
return {
|
||||
flush: () => {},
|
||||
|
|
|
@ -24,6 +24,7 @@ importers:
|
|||
jest-environment-jsdom: ^29.3.1
|
||||
jest-mock: ^29.3.1
|
||||
n8n: '*'
|
||||
nock: ^13.2.9
|
||||
node-fetch: ^2.6.7
|
||||
prettier: ^2.3.2
|
||||
rimraf: ^3.0.2
|
||||
|
@ -46,6 +47,7 @@ importers:
|
|||
jest: 29.3.1_@types+node@16.11.65
|
||||
jest-environment-jsdom: 29.3.1
|
||||
jest-mock: 29.3.1
|
||||
nock: 13.2.9
|
||||
node-fetch: 2.6.7
|
||||
prettier: 2.7.1
|
||||
rimraf: 3.0.2
|
||||
|
@ -15909,6 +15911,18 @@ packages:
|
|||
lower-case: 2.0.2
|
||||
tslib: 2.4.0
|
||||
|
||||
/nock/13.2.9:
|
||||
resolution: {integrity: sha512-1+XfJNYF1cjGB+TKMWi29eZ0b82QOvQs2YoLNzbpWGqFMtRQHTa57osqdGj4FrFPgkO4D4AZinzUJR9VvW3QUA==}
|
||||
engines: {node: '>= 10.13'}
|
||||
dependencies:
|
||||
debug: 4.3.4
|
||||
json-stringify-safe: 5.0.1
|
||||
lodash: 4.17.21
|
||||
propagate: 2.0.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/node-abort-controller/3.0.1:
|
||||
resolution: {integrity: sha512-/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw==}
|
||||
dev: false
|
||||
|
@ -17493,6 +17507,11 @@ packages:
|
|||
react-is: 16.13.1
|
||||
dev: true
|
||||
|
||||
/propagate/2.0.1:
|
||||
resolution: {integrity: sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: true
|
||||
|
||||
/property-expr/2.0.5:
|
||||
resolution: {integrity: sha512-IJUkICM5dP5znhCckHSv30Q4b5/JA5enCtkRHYaOVOAocnH/1BQEYTC5NMfT3AVl/iXKdr3aqQbQn9DxyWknwA==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue