Skip to content

Commit

Permalink
chore(cli): test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lynchbomb committed Oct 25, 2019
1 parent 09db45a commit cd1c6d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
28 changes: 10 additions & 18 deletions packages/cli/test/commands/trace.ts
Original file line number Diff line number Diff line change
@@ -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`);
}
);
});
Expand All @@ -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`);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/test-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { pathToFileURL } from 'url';
import { writeFileSync, mkdirpSync } from 'fs-extra';
import { tmpDir } from './setup';
import { join, resolve } from 'path';

Expand Down Expand Up @@ -55,3 +54,4 @@ export function generateFileStructure(
}
});
}
export const TRACE = resolve(join(process.cwd(), '/test/fixtures/trace.json'));

0 comments on commit cd1c6d2

Please sign in to comment.