diff --git a/lib/index.js b/lib/index.js index 829f54d..48108b4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -55,20 +55,12 @@ class MonocartReporter { this.tickTime = this.options.tickTime || 1000; this.tickStart(); - this.trends = []; - this.initTrendsAndDir(); - - const stateOptions = this.options.state; - if (stateOptions) { - this.bindFunctions(stateOptions); - this.stateServer = createStateServer(stateOptions); - } + this.init(); } - async initTrendsAndDir() { + async init() { - const cwd = Util.formatPath(process.cwd()); - this.options.cwd = cwd; + this.options.cwd = Util.formatPath(process.cwd()); // read trends from json before clean dir this.trends = await getTrends(this.options.trend); @@ -87,6 +79,12 @@ class MonocartReporter { if (this.options.copyAttachments) { this.options.attachmentsDir = path.resolve(outputDir, 'attachments'); } + + const stateOptions = this.options.state; + if (stateOptions) { + this.bindFunctions(stateOptions); + this.stateServer = createStateServer(stateOptions); + } } // ========================================================================== diff --git a/tests/home-page/home-page.spec.js b/tests/home-page/home-page.spec.js index d3e50fa..4f90d04 100644 --- a/tests/home-page/home-page.spec.js +++ b/tests/home-page/home-page.spec.js @@ -96,7 +96,7 @@ test('secrets and sensitive data', async ({ page }, testInfo) => { }); const context = await request.newContext(); - await context.get(`https://api.npmjs.org/?token=${process.env.TOKEN}`); + await context.get(`http://localhost:8090/?token=${process.env.TOKEN}`); });