-
Notifications
You must be signed in to change notification settings - Fork 57
/
ava.base.js
41 lines (33 loc) · 1.21 KB
/
ava.base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import fs, { existsSync } from 'fs'
import path from 'path'
import process from 'process'
import { isCI } from 'ci-info'
import * as execa from 'execa'
const { execaCommand } = execa
if (process.argv.includes('-w')) {
execaCommand('tsc -w', { cleanup: true })
}
// `tests-metadata.json` is created by running `npx lerna run test:measure --scope @netlify/build`
const testData = existsSync('tests-metadata.json') ? JSON.parse(fs.readFileSync('tests-metadata.json', 'utf-8')) : {}
const getOrder = (file) => {
const fileRelative = path.relative(process.cwd(), file).replace(/\\/g, '/')
if (testData[fileRelative]) {
return testData[fileRelative].order
}
console.warn(`Missing test metadata for ${fileRelative}`)
return Number.MAX_SAFE_INTEGER
}
const sortTestFiles = (file1, file2) => getOrder(file1) - getOrder(file2)
const config = {
files: ['packages/**/tests/*.{cjs,mjs,js}', 'packages/**/tests/**/tests.{cjs,mjs,js}'],
verbose: true,
timeout: '240s',
workerThreads: false,
ignoredByWatcher: ['packages/*/tests/*/fixtures/**'],
environmentVariables: {
FORCE_COLOR: '1',
},
// we only sort in CI to split efficiently across machines
...(isCI && { sortTestFiles }),
}
export default config