Unverified Commit 7038b623 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix occasional test failures (#25855)

parent 5be354ed
...@@ -20,6 +20,8 @@ const UNIT_TEST_EXT = '.unit.test.js' ...@@ -20,6 +20,8 @@ const UNIT_TEST_EXT = '.unit.test.js'
const DEV_TEST_EXT = '.dev.test.js' const DEV_TEST_EXT = '.dev.test.js'
const PROD_TEST_EXT = '.prod.test.js' const PROD_TEST_EXT = '.prod.test.js'
const NON_CONCURRENT_TESTS = ['test/integration/basic/test/index.test.js']
// which types we have configured to run separate // which types we have configured to run separate
const configuredTestTypes = [UNIT_TEST_EXT] const configuredTestTypes = [UNIT_TEST_EXT]
...@@ -217,6 +219,61 @@ async function main() { ...@@ -217,6 +219,61 @@ async function main() {
}) })
}) })
const nonConcurrentTestNames = []
testNames = testNames.filter((testName) => {
if (NON_CONCURRENT_TESTS.includes(testName)) {
nonConcurrentTestNames.push(testName)
return false
}
return true
})
// run non-concurrent test names separately and before
// concurrent ones
for (const test of nonConcurrentTestNames) {
let passed = false
for (let i = 0; i < NUM_RETRIES + 1; i++) {
try {
const time = await runTest(test, i > 0)
timings.push({
file: test,
time,
})
passed = true
break
} catch (err) {
if (i < NUM_RETRIES) {
try {
const testDir = path.dirname(path.join(__dirname, test))
console.log('Cleaning test files at', testDir)
await exec(`git clean -fdx "${testDir}"`)
await exec(`git checkout "${testDir}"`)
} catch (err) {}
}
}
}
if (!passed) {
console.error(`${test} failed to pass within ${NUM_RETRIES} retries`)
children.forEach((child) => child.kill())
if (isTestJob) {
try {
const testsOutput = await fs.readFile(`${test}${RESULTS_EXT}`, 'utf8')
console.log(
`--test output start--`,
testsOutput,
`--test output end--`
)
} catch (err) {
console.log(`Failed to load test output`, err)
}
}
process.exit(1)
}
}
await Promise.all( await Promise.all(
testNames.map(async (test) => { testNames.map(async (test) => {
await sema.acquire() await sema.acquire()
......
...@@ -30,7 +30,7 @@ const runTests = () => { ...@@ -30,7 +30,7 @@ const runTests = () => {
.click() .click()
.waitForElementByCss('#index') .waitForElementByCss('#index')
await browser.back() await browser.back().waitForElementByCss('#another')
expect(await browser.elementByCss('#another').text()).toBe('another page') expect(await browser.elementByCss('#another').text()).toBe('another page')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment