Skip to content

Commit 094b641

Browse files
daniel-jones-devJanEbbing
authored andcommitted
refactor: share nock setup among test files
1 parent e6bc67b commit 094b641

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/core.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ export const documentTranslationTestTimeout = 10000;
199199
// E2E tests need a significantly higher timeout limit
200200
export const testTimeout = 60000;
201201

202+
// Base URL for mocking out HTTP client
203+
export const urlToMockRegexp =
204+
/(https?:\/\/api.*\.deepl\.com)|(deepl-mock:\d+)|(https?:\/\/localhost:\d+)/;
205+
202206
module.exports = {
203207
exampleText,
204208
exampleDocumentInput,
@@ -213,5 +217,6 @@ module.exports = {
213217
documentTranslationTestTimeout,
214218
testTimeout,
215219
timeout,
220+
urlToMockRegexp,
216221
proxyConfig,
217222
};

tests/general.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import {
1515
withMockProxyServer,
1616
makeTranslator,
1717
proxyConfig,
18+
urlToMockRegexp,
1819
} from './core';
1920

2021
const serverUrl = process.env.DEEPL_SERVER_URL;
21-
const urlToMockRegexp =
22-
/(https?:\/\/api.*\.deepl\.com)|(deepl-mock:\d+)|(https?:\/\/localhost:\d+)/;
2322

2423
describe('general', () => {
2524
it('rejects empty authKey', () => {

0 commit comments

Comments
 (0)