This repository has been archived by the owner on Sep 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: save/compare results to/from file
- Loading branch information
Showing
9 changed files
with
155 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
.nyc_output | ||
test/tmp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
|
||
const yargs = require('yargs') | ||
const path = require('path') | ||
const fs = require('fs-extra') | ||
const cli = require('../src/cli') | ||
const expect = require('chai').expect | ||
const { start } = require('../src/index') | ||
|
||
const benchmarks = require(process.cwd() + '/test/benchmarks') | ||
|
||
describe('CLI Compare', function () { | ||
this.timeout(6000) | ||
|
||
it('should compare results to file', async () => { | ||
const yargsCmd = yargs.command(cli) | ||
const tmpFile = path.join(__dirname, 'tmp/benchmark.json') | ||
const yargsResult1 = yargsCmd.parse( | ||
`cli --baseline -s ${tmpFile}`, {} | ||
) | ||
|
||
await start(benchmarks, yargsResult1) | ||
|
||
const yargsResult2 = yargsCmd.parse( | ||
`cli --baseline -r -c ${tmpFile}`, {} | ||
) | ||
await start(benchmarks, yargsResult2) | ||
|
||
// TODO - test reporter output | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
|
||
const yargs = require('yargs') | ||
const path = require('path') | ||
const fs = require('fs-extra') | ||
const cli = require('../src/cli') | ||
const expect = require('chai').expect | ||
const { start } = require('../src/index') | ||
|
||
const benchmarks = require(process.cwd() + '/test/benchmarks') | ||
|
||
describe('CLI Save', function () { | ||
this.timeout(6000) | ||
|
||
it('should save results to file', async () => { | ||
const yargsCmd = yargs.command(cli) | ||
const tmpFile = path.join(__dirname, 'tmp/benchmark.json') | ||
const yargsResult = yargsCmd.parse( | ||
`cli --baseline -s ${tmpFile}`, {} | ||
) | ||
|
||
await start(benchmarks, yargsResult) | ||
|
||
const results = fs.readJsonSync(tmpFile) | ||
expect(results).to.be.an('array') | ||
expect(results.length).to.be.equal(1) | ||
|
||
const benchmark = results[0] | ||
expect(benchmark).to.have.property('name') | ||
expect(benchmark).to.have.property('cpus') | ||
expect(benchmark).to.have.property('loadavg') | ||
expect(benchmark).to.have.property('elapsed') | ||
expect(benchmark).to.have.property('stats') | ||
expect(benchmark).to.have.property('memory') | ||
|
||
expect(benchmark.name).to.be.equal('console-baseline') | ||
expect(benchmark.memory).to.have.property('before') | ||
expect(benchmark.memory).to.have.property('after') | ||
expect(benchmark.stats).to.have.property('count') | ||
}) | ||
}) |