test: fix flaky contentTracing.startRecording spec (#31409)

This commit is contained in:
Cheng Zhao 2021-10-13 23:06:29 +09:00 committed by GitHub
parent b99b4e7f22
commit a751845afc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,18 +52,10 @@ ifdescribe(!(['arm', 'arm64'].includes(process.arch)))('contentTracing', () => {
}; };
await record(config, outputFilePath); await record(config, outputFilePath);
expect(fs.existsSync(outputFilePath)).to.be.true('output exists'); // If the `excluded_categories` param above is not respected, categories
// like `node,node.environment` will be included in the output.
// If the `excluded_categories` param above is not respected const content = fs.readFileSync(outputFilePath).toString();
// the file size will be above 50KB. expect(content.includes('"cat":"node,node.environment"')).to.be.false();
const fileSizeInKiloBytes = getFileSizeInKiloBytes(outputFilePath);
const expectedMaximumFileSize = 10; // Depends on a platform.
expect(fileSizeInKiloBytes).to.be.above(0,
`the trace output file is empty, check "${outputFilePath}"`);
expect(fileSizeInKiloBytes).to.be.below(expectedMaximumFileSize,
`the trace output file is suspiciously large (${fileSizeInKiloBytes}KB),
check "${outputFilePath}"`);
}); });
it('accepts "categoryFilter" and "traceOptions" as a config', async () => { it('accepts "categoryFilter" and "traceOptions" as a config', async () => {