From cd1c6d25390d704fe05714172b41e60b6af1ee50 Mon Sep 17 00:00:00 2001 From: Marc Lynch Date: Wed, 16 Oct 2019 10:27:54 -0700 Subject: [PATCH] chore(cli): test cleanup --- packages/cli/test/commands/trace.ts | 28 ++++++++++------------------ packages/cli/test/test-helpers.ts | 2 +- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/cli/test/commands/trace.ts b/packages/cli/test/commands/trace.ts index 6f6365ea..1bd532e3 100644 --- a/packages/cli/test/commands/trace.ts +++ b/packages/cli/test/commands/trace.ts @@ -1,33 +1,27 @@ import { test } from '@oclif/test'; -import { use, expect } from 'chai'; +import { assert, expect } from 'chai'; import Trace from '../../src/commands/trace'; -import { COOKIES, TB_RESULTS_FOLDER, URL, HAR_PATH } from '../test-helpers'; +import { TB_RESULTS_FOLDER, URL } from '../test-helpers'; -const chaiFiles = require('chai-files'); -use(chaiFiles); - -const file = chaiFiles.file; +const cpuThrottleRate = '1'; describe('trace', () => { test .stdout() .it( - `runs trace --url ${URL} --tbResultsFolder ${TB_RESULTS_FOLDER} --harpath ${HAR_PATH} --cookiespath ${COOKIES}`, + `runs trace --url ${URL} --tbResultsFolder ${TB_RESULTS_FOLDER} --cpuThrottleRate ${cpuThrottleRate}`, async ctx => { await Trace.run([ '--url', URL, '--tbResultsFolder', TB_RESULTS_FOLDER, - '--harpath', - HAR_PATH, - '--cookiespath', - COOKIES, + '--cpuThrottleRate', + cpuThrottleRate, ]); expect(ctx.stdout).to.contain(`Trace`); expect(ctx.stdout).to.contain(`Subtotal`); - // tslint:disable-next-line: no-unused-expression - expect(file(`${TB_RESULTS_FOLDER}/trace.json`)).to.exist; + assert.exists(`${TB_RESULTS_FOLDER}/trace.json`); } ); }); @@ -36,17 +30,15 @@ describe('trace: insights', () => { test .stdout() .it( - `runs trace --url ${URL} --tbResultsFolder ${TB_RESULTS_FOLDER} --harpath ${HAR_PATH} --cookiespath ${COOKIES} --insights`, + `runs trace --url ${URL} --tbResultsFolder ${TB_RESULTS_FOLDER} --cpuThrottleRate ${cpuThrottleRate} --insights`, async ctx => { await Trace.run([ '--url', URL, '--tbResultsFolder', TB_RESULTS_FOLDER, - '--harpath', - HAR_PATH, - '--cookiespath', - COOKIES, + '--cpuThrottleRate', + cpuThrottleRate, '--insights', ]); expect(ctx.stdout).to.contain(`.js`); diff --git a/packages/cli/test/test-helpers.ts b/packages/cli/test/test-helpers.ts index 1e6253ce..ab7cf486 100644 --- a/packages/cli/test/test-helpers.ts +++ b/packages/cli/test/test-helpers.ts @@ -1,5 +1,4 @@ import { pathToFileURL } from 'url'; -import { writeFileSync, mkdirpSync } from 'fs-extra'; import { tmpDir } from './setup'; import { join, resolve } from 'path'; @@ -55,3 +54,4 @@ export function generateFileStructure( } }); } +export const TRACE = resolve(join(process.cwd(), '/test/fixtures/trace.json'));