Skip to content

Commit

Permalink
wip: test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Oct 19, 2023
1 parent b609df2 commit 12141a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node_version: [16, 18, 20]
# node_version: [16, 18, 20]
node-version: [18]
include:
# Active LTS + other OS
- os: macos-latest
node_version: 18
# - os: macos-latest
# node_version: 18
- os: windows-latest
node_version: 18
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions playground/spa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export default defineConfig(() => ({
},
{
attrs: {
'src': manifest.haha,
'data-n': '1',
src: manifest.haha,
},
injectTo: 'head',
},
Expand All @@ -41,6 +40,7 @@ export default defineConfig(() => ({
attrs: {
src: manifest.test,
},
injectTo: 'body-prepend',
},
]),
],
Expand Down
16 changes: 9 additions & 7 deletions playground/vitestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,23 @@ beforeAll(async (s) => {
}

try {
page.on('console', (msg) => {
page.addListener('console', async (msg) => {
// ignore favicon request in headed browser
if (
// process.env.VITE_DEBUG_SERVE &&
process.env.VITE_DEBUG_SERVE &&
msg.text().includes('Failed to load resource:') &&
msg.location().url.includes('favicon.ico')
) {
console.log(msg, 'msg')
return
}
if (['React DevTools'].some((i) => msg.text().includes(i))) {
return
}
browserLogs.push(msg.text())
})
page.on('pageerror', (error) => {

page.addListener('pageerror', (error) => {
browserErrors.push(error)
})

Expand Down Expand Up @@ -343,7 +345,7 @@ function loadConfigFromDir(dir: string) {
}

async function goToUrlAndWaitForViteWSConnect(page: Page, url: string) {
return Promise.all([page.goto(url), waitForViteConnect(page, 50000)])
return Promise.all([page.goto(url), waitForViteConnect(page, 15000)])
}

export async function waitForViteConnect(page: Page, timeoutMS = 5000) {
Expand All @@ -362,15 +364,15 @@ export async function waitForViteConnect(page: Page, timeoutMS = 5000) {
pageConsoleListener = (data) => {
const text = data.text()
if (text.includes('[vite] connected.')) {
console.log(browserLogs, 'browserLogs')
console.log(browserLogs, '<==== browserLogs on vite connected')
resolve()
}
}
page.on('console', pageConsoleListener)
page.addListener('console', pageConsoleListener)
})

return Promise.race([connectedPromise, timeoutPromise]).finally(() => {
page.off('console', pageConsoleListener)
page.removeListener('console', pageConsoleListener)
clearTimeout(timerId)
})
}

0 comments on commit 12141a5

Please sign in to comment.