Skip to content

Commit 3f8b369

Browse files
committed
Added test timer
1 parent 66a5f49 commit 3f8b369

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const {run} = require('../bin/cli');
88
const {parseFile, stringify, writeFile} = require('../openapi-format');
99

1010
// SELECTIVE TESTING DEBUG
11-
const localTesting = false;
11+
const localTesting = true;
1212
const destroyOutput = false;
1313

1414
// Load tests
1515
const tests = !localTesting
1616
? fs.readdirSync(__dirname).filter(file => {
17-
return fs.statSync(path.join(__dirname, file)).isDirectory() && !file.startsWith('_');
18-
})
19-
: ['overlay-preserve-required'];
17+
return fs.statSync(path.join(__dirname, file)).isDirectory() && !file.startsWith('_');
18+
})
19+
: ['yaml-filter-unused-components-path'];
2020

2121
describe('openapi-format tests', () => {
2222
let consoleLogSpy, consoleWarnSpy;
@@ -34,6 +34,8 @@ describe('openapi-format tests', () => {
3434
tests.forEach(test => {
3535
describe(test, () => {
3636
it('should match expected output', async () => {
37+
const start = process.hrtime();
38+
3739
let options = {};
3840
let configFileOptions = {};
3941
let inputFilename = null;
@@ -133,8 +135,14 @@ describe('openapi-format tests', () => {
133135
console.error('error', error);
134136
}
135137

136-
// Assert results with output
137-
expect(result).toStrictEqual(snap);
138+
try {
139+
// Assert results with output
140+
expect(result).toStrictEqual(snap);
141+
} finally {
142+
const [sec, nano] = process.hrtime(start);
143+
const ms = (sec * 1e3 + nano / 1e6).toFixed(2);
144+
process.stderr.write(`Test "${test}" took ${ms} ms\n`);
145+
}
138146
});
139147
});
140148
});

0 commit comments

Comments
 (0)