From edbc6f770a5943be01ace6a522302bdfa1c0997c Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Sun, 25 Jun 2023 21:55:25 -0700 Subject: [PATCH] jest test running! --- src/core/render/compiler.js | 1 - test/config/jest.setup.js | 2 +- test/config/jest.teardown.js | 2 +- test/config/playwright.setup.js | 2 +- test/config/playwright.teardown.js | 2 +- test/config/server.js | 12 ++++++------ test/helpers/docsify-init.js | 5 +++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index fa9cee2e7..b68881485 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -115,7 +115,6 @@ export class Compiler { })(text); const curFileName = this.router.parse().file; - console.log('filename:', curFileName); if (isCached) { this.toc = this.cacheTOC[curFileName]; diff --git a/test/config/jest.setup.js b/test/config/jest.setup.js index 65f2ad509..cb70e5dd9 100644 --- a/test/config/jest.setup.js +++ b/test/config/jest.setup.js @@ -1,4 +1,4 @@ -import * as server from './server.js'; +import server from './server.js'; export default async () => { await server.startAsync(); diff --git a/test/config/jest.teardown.js b/test/config/jest.teardown.js index 6f939807f..e08dc6ff6 100644 --- a/test/config/jest.teardown.js +++ b/test/config/jest.teardown.js @@ -1,4 +1,4 @@ -import * as server from './server.js'; +import server from './server.js'; export default async () => { server.stop(); diff --git a/test/config/playwright.setup.js b/test/config/playwright.setup.js index c405c6957..92bb776f1 100644 --- a/test/config/playwright.setup.js +++ b/test/config/playwright.setup.js @@ -1,4 +1,4 @@ -import * as server from './server.js'; +import server from './server.js'; export default async config => { await server.startAsync(); diff --git a/test/config/playwright.teardown.js b/test/config/playwright.teardown.js index d04e8b1e8..16292c49e 100644 --- a/test/config/playwright.teardown.js +++ b/test/config/playwright.teardown.js @@ -1,4 +1,4 @@ -import * as server from './server.js'; +import server from './server.js'; export default async config => { server.stop(); diff --git a/test/config/server.js b/test/config/server.js index 19ec2f943..c066ebd17 100644 --- a/test/config/server.js +++ b/test/config/server.js @@ -10,10 +10,11 @@ const serverConfig = { port: hasStartArg ? 3002 : 3001, }; -const TEST_HOST = `http://${serverConfig.hostname}:${serverConfig.port}`; const __filename = url.fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +export const TEST_HOST = `http://${serverConfig.hostname}:${serverConfig.port}`; + function startServer(options = {}, cb = Function.prototype) { const defaults = { ...serverConfig, @@ -130,9 +131,8 @@ function isMain(meta) { return false; } -export { - startServer as start, - startServerAsync as startAsync, - stopServer as stop, - TEST_HOST, +export default { + start: startServer, + startAsync: startServerAsync, + stop: stopServer, }; diff --git a/test/helpers/docsify-init.js b/test/helpers/docsify-init.js index 83a2e5f4e..4f2ef4e13 100644 --- a/test/helpers/docsify-init.js +++ b/test/helpers/docsify-init.js @@ -263,7 +263,8 @@ async function docsifyInit(options = {}) { const isDocsifyLoaded = 'Docsify' in window; if (!isDocsifyLoaded) { - require(docsifyPATH); + // require(docsifyPATH); + await import(docsifyPATH); } } else if (isPlaywright) { for (const url of settings.scriptURLs) { @@ -359,4 +360,4 @@ async function docsifyInit(options = {}) { return Promise.resolve(); } -module.exports = docsifyInit; +export default docsifyInit;