Skip to content

Commit

Permalink
test: transpileOnly flag for ts-node
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork committed Dec 31, 2024
1 parent f565174 commit 4227a74
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
47 changes: 23 additions & 24 deletions ava.base.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
import fs, { existsSync } from 'fs'
import path from 'path'
import process from 'process'
// import fs, { existsSync } from 'fs'
// import path from 'path'
// import process from 'process'

import { isCI } from 'ci-info'
import * as execa from 'execa'
// import { isCI } from 'ci-info'
// import * as execa from 'execa'

const { execaCommand } = execa
if (process.argv.includes('-w')) {
execaCommand('tsc -w', { cleanup: true })
}
// 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')) : {}
// // `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
}
// 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
}
// console.warn(`Missing test metadata for ${fileRelative}`)
// return Number.MAX_SAFE_INTEGER
// }

const sortTestFiles = (file1, file2) => getOrder(file1) - getOrder(file2)
// 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/**'],
// workerThreads: false,
environmentVariables: {
FORCE_COLOR: '1',
},
// we only sort in CI to split efficiently across machines
...(isCI && { sortTestFiles }),
// // we only sort in CI to split efficiently across machines
// ...(isCI && { sortTestFiles }),
}

export default config
2 changes: 1 addition & 1 deletion packages/build/ava.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import baseConfig from '../../ava.base.js'

const config = {
...baseConfig,
files: ['tests/*.{cjs,mjs,js}', 'tests/**/tests.{cjs,mjs,js}'],
files: ['tests/**/tests.{cjs,mjs,js}'],
}

export default config
5 changes: 4 additions & 1 deletion packages/build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"outDir": "lib" /* Specify an output folder for all emitted files. */
},
"include": ["src/**/*.js", "src/**/*.ts"],
"exclude": ["tests/**"]
"exclude": ["tests/**"],
"ts-node": {
"transpileOnly": true
}
}

0 comments on commit 4227a74

Please sign in to comment.