mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Fix Jest memory issues
This commit is contained in:
parent
90e11def54
commit
26f24aa76c
@ -1,4 +1,38 @@
|
||||
const os = require('os');
|
||||
const v8 = require('v8');
|
||||
|
||||
// Several parts inspired by https://github.com/renovatebot/renovate/blob/main/package.json
|
||||
|
||||
const ci = !!process.env.CI;
|
||||
|
||||
const cpus = os.cpus();
|
||||
const mem = os.totalmem();
|
||||
const stats = v8.getHeapStatistics();
|
||||
|
||||
if (ci) {
|
||||
process.stderr.write(`Host stats:
|
||||
Cpus: ${cpus.length}
|
||||
Memory: ${(mem / 1024 / 1024 / 1024).toFixed(2)} GB
|
||||
HeapLimit: ${(stats.heap_size_limit / 1024 / 1024 / 1024).toFixed(2)} GB
|
||||
`);
|
||||
}
|
||||
|
||||
// See also https://github.com/jestjs/jest/issues/11956
|
||||
function jestGithubRunnerSpecs() {
|
||||
return {
|
||||
maxWorkers: cpus.length,
|
||||
workerIdleMemoryLimit: '1500MB',
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
transform: {
|
||||
'^.+\\.ts$': [ 'ts-jest', {
|
||||
tsconfig: '<rootDir>/tsconfig.json',
|
||||
diagnostics: false,
|
||||
isolatedModules: true,
|
||||
}],
|
||||
},
|
||||
testRegex: '/test/(unit|integration)/.*\\.test\\.ts$',
|
||||
moduleFileExtensions: [
|
||||
'ts',
|
||||
@ -13,5 +47,7 @@ module.exports = {
|
||||
},
|
||||
// Slower machines had problems calling the WebSocket integration callbacks on time
|
||||
testTimeout: 60000,
|
||||
preset: 'ts-jest',
|
||||
|
||||
reporters: ci ? ['default', 'github-actions'] : ['default'],
|
||||
...(ci && jestGithubRunnerSpecs()),
|
||||
};
|
||||
|
@ -68,7 +68,7 @@
|
||||
"test": "npm run test:ts && npm run jest",
|
||||
"test:deploy": "test/deploy/validate-configs.sh",
|
||||
"test:ts": "tsc -p test --noEmit",
|
||||
"test:integration": "node --expose-gc --no-compilation-cache ./node_modules/jest/bin/jest.js -- test/integration",
|
||||
"test:integration": "jest test/integration",
|
||||
"test:unit": "jest --config=./jest.coverage.config.js test/unit",
|
||||
"test:watch": "jest --coverageReporters none --watch test/unit",
|
||||
"validate": "componentsjs-compile-config urn:solid-server:default:Initializer -c config/default.json -f > /dev/null",
|
||||
|
Loading…
x
Reference in New Issue
Block a user