MCPcopy
hub / github.com/vercel/next.js / runTestOnce

Function runTestOnce

run-tests.js:514–694  ·  view source on GitHub ↗
(/** @type {TestFile} */ test, isFinalRun, isRetry)

Source from the content-addressed store, hash-verified

512 let hadFailures = false
513
514 const runTestOnce = (/** @type {TestFile} */ test, isFinalRun, isRetry) =>
515 new Promise((resolve, reject) => {
516 const start = new Date().getTime()
517 let outputChunks = []
518
519 const args = [
520 ...(process.env.CI ? ['--ci'] : []),
521 '--runInBand',
522 '--forceExit',
523 '--no-cache',
524 '--verbose',
525 ...(isTestJob
526 ? ['--json', `--outputFile=${test.file}${RESULTS_EXT}`]
527 : []),
528 test.file,
529 ...(test.excludedCases.length === 0
530 ? []
531 : [
532 '--testNamePattern',
533 `^(?!(?:${test.excludedCases.map(escapeRegexp).join('|')})$).`,
534 ]),
535 ]
536 const deferNextTestWasm = !!process.env.NEXT_TEST_WASM
537 const env = {
538 // run tests in headless mode by default
539 HEADLESS: 'true',
540 NEXT_TELEMETRY_DISABLED: '1',
541 // unset CI env so CI behavior is only explicitly
542 // tested when enabled
543 CI: '',
544 // But some tests need to fork based on machine? CI? behavior differences
545 // Only use this in tests.
546 // For implementation forks, use `process.env.CI` instead
547 NEXT_TEST_CI: process.env.CI,
548
549 ...(options.local
550 ? {}
551 : {
552 IS_RETRY: isRetry ? 'true' : undefined,
553 TRACE_PLAYWRIGHT: 'true',
554 CIRCLECI: '',
555 GITHUB_ACTIONS: '',
556 CONTINUOUS_INTEGRATION: '',
557 RUN_ID: '',
558 BUILD_NUMBER: '',
559 // Format the output of junit report to include the test name
560 // For the debugging purpose to compare actual run list to the generated reports
561 // [NOTE]: This won't affect if junit reporter is not enabled
562 JEST_JUNIT_OUTPUT_NAME: test.file.replaceAll('/', '_'),
563 // Specify suite name for the test to avoid unexpected merging across different env / grouped tests
564 // This is not individual suites name (corresponding 'describe'), top level suite name which have redundant names by default
565 // [NOTE]: This won't affect if junit reporter is not enabled
566 JEST_SUITE_NAME: [
567 `${process.env.NEXT_TEST_MODE ?? 'default'}`,
568 options.group,
569 options.type,
570 test.file,
571 ]

Callers 1

runTestFunction · 0.85

Calls 15

handleOutputFunction · 0.70
setMethod · 0.65
replaceMethod · 0.65
resolveFunction · 0.50
spawnFunction · 0.50
rejectFunction · 0.50
joinMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
entriesMethod · 0.45
onMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…