Skip to content

Commit

Permalink
chore: update build tests for Vite 5 ecosystem-ci (vite-pwa#582)
Browse files Browse the repository at this point in the history
* chore: update build tests for Vite 5 ecosystem-ci

* chore: bupt to pnpm 8.9.2
  • Loading branch information
userquin authored Oct 25, 2023
1 parent b820276 commit 17cddee
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 19 deletions.
20 changes: 17 additions & 3 deletions examples/preact-router/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,23 @@ describe('Preact: test-build', () => {
let match: RegExpMatchArray | null
if (!injectManifest) {
match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
Expand Down
20 changes: 17 additions & 3 deletions examples/react-router/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ describe('React: test-build', () => {
let match: RegExpMatchArray | null
if (!injectManifest) {
match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
Expand Down
20 changes: 17 additions & 3 deletions examples/solid-router/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ describe('Solid: test-build', () => {
let match: RegExpMatchArray | null
if (!injectManifest) {
match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
Expand Down
20 changes: 17 additions & 3 deletions examples/svelte-routify/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ describe('Svelte: test-build', () => {
let match: RegExpMatchArray | null
if (!injectManifest) {
match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
Expand Down
20 changes: 17 additions & 3 deletions examples/vanilla-ts-no-ip/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,23 @@ describe('Typescript (no injection point): test-build', () => {
expect(existsSync(webManifest), `${webManifest} doesn't exist`).toBeTruthy()
const swContent = readFileSync(swPath, 'utf-8')
let match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
match = swContent.match(/"url":\s*"index.html"/)
Expand Down
20 changes: 17 additions & 3 deletions examples/vue-router/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ describe('Vue 3: test-build', () => {
let match: RegExpMatchArray | null
if (!injectManifest) {
match = swContent.match(/define\(\['\.\/(workbox-\w+)'/)
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
// vite 5 beta 8 change rollup from v3 to v4: sw deps now inlined
if (match) {
expect(match && match.length === 2, `workbox-***.js entry not found in ${swName}`).toBeTruthy()
const workboxName = resolvePath(_dirname, `../dist/${match?.[1]}.js`)
expect(existsSync(workboxName), `${workboxName} doesn't exist`).toBeTruthy()
const workboxContent = readFileSync(workboxName, 'utf-8')
match = workboxContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*workbox\.clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
else {
match = swContent.match(/self\['workbox:core:[0-9.]+']/)
expect(match && match.length === 1, 'missing workbox:core module').toBeTruthy()
match = swContent.match(/self\.skipWaiting\(\);?\s*clientsClaim\(\)/)
expect(match && match.length === 1, 'missing self.skipWaiting and clientsClaim workbox calls').toBeTruthy()
}
}
match = swContent.match(/"url":\s*"manifest\.webmanifest"/)
expect(match && match.length === 1, 'missing manifest.webmanifest in sw precache manifest').toBeTruthy()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vite-plugin-pwa",
"type": "module",
"version": "0.16.5",
"packageManager": "pnpm@8.7.4",
"packageManager": "pnpm@8.9.2",
"description": "Zero-config PWA for Vite",
"author": "antfu <[email protected]>",
"license": "MIT",
Expand Down

0 comments on commit 17cddee

Please sign in to comment.