Remove BLANK_URL global

This commit is contained in:
John Hildenbiddle 2020-11-11 16:57:22 -06:00
parent 69efae3c4f
commit 51451a40f7
6 changed files with 8 additions and 16 deletions

View File

@ -1,9 +1,9 @@
const { globals: serverGlobals } = require('./test/config/server.js'); const { TEST_HOST } = require('./test/config/server.js');
const sharedConfig = { const sharedConfig = {
errorOnDeprecated: true, errorOnDeprecated: true,
globals: { globals: {
...serverGlobals, // BLANK_URL, TEST_HOST TEST_HOST,
}, },
globalSetup: './test/config/jest.setup.js', globalSetup: './test/config/jest.setup.js',
globalTeardown: './test/config/jest.teardown.js', globalTeardown: './test/config/jest.teardown.js',
@ -23,7 +23,7 @@ module.exports = {
displayName: 'unit', displayName: 'unit',
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'], setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
testMatch: ['<rootDir>/test/unit/*.test.js'], testMatch: ['<rootDir>/test/unit/*.test.js'],
testURL: serverGlobals.BLANK_URL, testURL: `${TEST_HOST}/_blank.html`,
}, },
// Integration Tests (Jest) // Integration Tests (Jest)
{ {
@ -31,7 +31,7 @@ module.exports = {
displayName: 'integration', displayName: 'integration',
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'], setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
testMatch: ['<rootDir>/test/integration/*.test.js'], testMatch: ['<rootDir>/test/integration/*.test.js'],
testURL: serverGlobals.BLANK_URL, testURL: `${TEST_HOST}/_blank.html`,
}, },
// E2E Tests (Jest + Playwright) // E2E Tests (Jest + Playwright)
{ {

View File

@ -5,8 +5,6 @@ module.exports = {
'jest/globals': true, 'jest/globals': true,
}, },
extends: ['plugin:jest/recommended', 'plugin:jest/style'], extends: ['plugin:jest/recommended', 'plugin:jest/style'],
globals: { globals: jestConfig.globals,
...jestConfig.globals,
},
plugins: ['jest'], plugins: ['jest'],
}; };

View File

@ -14,7 +14,6 @@
## Global Variables ## Global Variables
- `BLANK_URL`: Test server route to virtual `_blank.html` file
- `TEST_HOST`: Test server ip:port - `TEST_HOST`: Test server ip:port
## CLI commands ## CLI commands

View File

@ -50,5 +50,5 @@ beforeEach(async () => {
// will cause operations that require the window location to be a valid URL // 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 // to fail (e.g. AJAX requests). To avoid these issues, this hook ensures
// that each tests begins by a blank HTML page. // that each tests begins by a blank HTML page.
await page.goto(BLANK_URL); await page.goto(`${TEST_HOST}/_blank.html`);
}); });

View File

@ -104,13 +104,8 @@ else if (require.main === module) {
} }
module.exports = { module.exports = {
globals: {
get BLANK_URL() {
return `${this.TEST_HOST}/_blank.html`;
},
TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`,
},
start: startServer, start: startServer,
startAsync: startServerAsync, startAsync: startServerAsync,
stop: stopServer, stop: stopServer,
TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`,
}; };

View File

@ -92,7 +92,7 @@ describe(`Example Tests`, function() {
test('manual docsify site using playwright methods', async () => { test('manual docsify site using playwright methods', async () => {
// Goto URL // Goto URL
// https://playwright.dev/#path=docs%2Fapi.md&q=pagegotourl-options // 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 // Set docsify configuration
// https://playwright.dev/#path=docs%2Fapi.md&q=pageevaluatepagefunction-arg // https://playwright.dev/#path=docs%2Fapi.md&q=pageevaluatepagefunction-arg