mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: add memory debugging to mocha runner (#11722)
This commit is contained in:
parent
d17a9df027
commit
afa3fd4c34
@ -169,6 +169,21 @@ export const setupTestBrowserHooks = (): void => {
|
||||
// if browser is not found
|
||||
}
|
||||
});
|
||||
|
||||
after(() => {
|
||||
if (typeof gc !== 'undefined') {
|
||||
gc();
|
||||
const memory = process.memoryUsage();
|
||||
console.log('Memory stats:');
|
||||
for (const key of Object.keys(memory)) {
|
||||
console.log(
|
||||
key,
|
||||
// @ts-expect-error TS cannot the key type.
|
||||
`${Math.round(((memory[key] / 1024 / 1024) * 100) / 100)} MB`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const getTestState = async (
|
||||
|
@ -46,6 +46,7 @@ const {
|
||||
minTests,
|
||||
shard,
|
||||
reporter,
|
||||
printMemory,
|
||||
} = yargs(hideBin(process.argv))
|
||||
.parserConfiguration({'unknown-options-as-args': true})
|
||||
.scriptName('@puppeteer/mocha-runner')
|
||||
@ -82,6 +83,10 @@ const {
|
||||
string: true,
|
||||
requiresArg: true,
|
||||
})
|
||||
.option('print-memory', {
|
||||
boolean: true,
|
||||
default: false,
|
||||
})
|
||||
.parseSync();
|
||||
|
||||
function getApplicableTestSuites(
|
||||
@ -197,6 +202,10 @@ async function main() {
|
||||
'trace-warnings',
|
||||
];
|
||||
|
||||
if (printMemory) {
|
||||
args.push('-n', 'expose-gc');
|
||||
}
|
||||
|
||||
const specPattern = 'test/build/**/*.spec.js';
|
||||
const specs = globSync(specPattern, {
|
||||
ignore: !includeCdpTests ? 'test/build/cdp/**/*.spec.js' : undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user