From 51451a40f7a15bc167769a580019245afab38b47 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Wed, 11 Nov 2020 16:57:22 -0600 Subject: [PATCH] Remove BLANK_URL global --- jest.config.js | 8 ++++---- test/.eslintrc.js | 4 +--- test/README.md | 1 - test/config/jest-playwright.setup-tests.js | 2 +- test/config/server.js | 7 +------ test/e2e/example.test.js | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/jest.config.js b/jest.config.js index 845aab4..09594dc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,9 +1,9 @@ -const { globals: serverGlobals } = require('./test/config/server.js'); +const { TEST_HOST } = require('./test/config/server.js'); const sharedConfig = { errorOnDeprecated: true, globals: { - ...serverGlobals, // BLANK_URL, TEST_HOST + TEST_HOST, }, globalSetup: './test/config/jest.setup.js', globalTeardown: './test/config/jest.teardown.js', @@ -23,7 +23,7 @@ module.exports = { displayName: 'unit', setupFilesAfterEnv: ['/test/config/jest.setup-tests.js'], testMatch: ['/test/unit/*.test.js'], - testURL: serverGlobals.BLANK_URL, + testURL: `${TEST_HOST}/_blank.html`, }, // Integration Tests (Jest) { @@ -31,7 +31,7 @@ module.exports = { displayName: 'integration', setupFilesAfterEnv: ['/test/config/jest.setup-tests.js'], testMatch: ['/test/integration/*.test.js'], - testURL: serverGlobals.BLANK_URL, + testURL: `${TEST_HOST}/_blank.html`, }, // E2E Tests (Jest + Playwright) { diff --git a/test/.eslintrc.js b/test/.eslintrc.js index e273ac7..1609f15 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -5,8 +5,6 @@ module.exports = { 'jest/globals': true, }, extends: ['plugin:jest/recommended', 'plugin:jest/style'], - globals: { - ...jestConfig.globals, - }, + globals: jestConfig.globals, plugins: ['jest'], }; diff --git a/test/README.md b/test/README.md index eca1b05..dd1a8cb 100644 --- a/test/README.md +++ b/test/README.md @@ -14,7 +14,6 @@ ## Global Variables -- `BLANK_URL`: Test server route to virtual `_blank.html` file - `TEST_HOST`: Test server ip:port ## CLI commands diff --git a/test/config/jest-playwright.setup-tests.js b/test/config/jest-playwright.setup-tests.js index d6cba62..f438efa 100644 --- a/test/config/jest-playwright.setup-tests.js +++ b/test/config/jest-playwright.setup-tests.js @@ -50,5 +50,5 @@ beforeEach(async () => { // will cause operations that require the window location to be a valid URL // to fail (e.g. AJAX requests). To avoid these issues, this hook ensures // that each tests begins by a blank HTML page. - await page.goto(BLANK_URL); + await page.goto(`${TEST_HOST}/_blank.html`); }); diff --git a/test/config/server.js b/test/config/server.js index 031842e..acb5b29 100644 --- a/test/config/server.js +++ b/test/config/server.js @@ -104,13 +104,8 @@ else if (require.main === module) { } module.exports = { - globals: { - get BLANK_URL() { - return `${this.TEST_HOST}/_blank.html`; - }, - TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`, - }, start: startServer, startAsync: startServerAsync, stop: stopServer, + TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`, }; diff --git a/test/e2e/example.test.js b/test/e2e/example.test.js index ae93eb8..5226678 100644 --- a/test/e2e/example.test.js +++ b/test/e2e/example.test.js @@ -92,7 +92,7 @@ describe(`Example Tests`, function() { test('manual docsify site using playwright methods', async () => { // Goto URL // https://playwright.dev/#path=docs%2Fapi.md&q=pagegotourl-options - await page.goto(BLANK_URL); + await page.goto(`${TEST_HOST}/_blank.html`); // Set docsify configuration // https://playwright.dev/#path=docs%2Fapi.md&q=pageevaluatepagefunction-arg