Skip to content

Commit

Permalink
test: fix e2e HMR test
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Mar 26, 2024
1 parent 416d4bd commit 196902d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
15 changes: 9 additions & 6 deletions test/e2e/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,38 @@ describe('react e2e test', () => {
const getUrl = (path: string) => `http://localhost:${server.config.server.port}${path}`

it('/blog/today have content', async () => {
await page.goto(getUrl('/blog/today'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/blog/today'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today/index')
})

it('/blog/today/xxx - nested cache all', async () => {
await page.goto(getUrl('/blog/today/xxx'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/blog/today/xxx'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today ...all route')
})

it('/xxx/xxx - cache all route', async () => {
await page.goto(getUrl('/xxx/xxx'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/xxx/xxx'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('...all route')
})

it('/blog/1b234bk12b3 - dynamic route', async () => {
await page.goto(getUrl('/blog/1b234bk12b3'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/blog/1b234bk12b3'))
const text = await page.locator('body > div > p').textContent()
expect(text?.trim()).toBe('blog/[id].tsx: 1b234bk12b3')

Check failure on line 58 in test/e2e/react.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16)

test/e2e/react.test.ts > react e2e test > /blog/1b234bk12b3 - dynamic route

AssertionError: expected 'Loading...' to be 'blog/[id].tsx: 1b234bk12b3' // Object.is equality - Expected + Received - blog/[id].tsx: 1b234bk12b3 + Loading... ❯ test/e2e/react.test.ts:58:26

Check failure on line 58 in test/e2e/react.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

test/e2e/react.test.ts > react e2e test > /blog/1b234bk12b3 - dynamic route

AssertionError: expected 'Loading...' to be 'blog/[id].tsx: 1b234bk12b3' // Object.is equality - Expected + Received - blog/[id].tsx: 1b234bk12b3 + Loading... ❯ test/e2e/react.test.ts:58:26

Check failure on line 58 in test/e2e/react.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20)

test/e2e/react.test.ts > react e2e test > /blog/1b234bk12b3 - dynamic route

AssertionError: expected 'Loading...' to be 'blog/[id].tsx: 1b234bk12b3' // Object.is equality - Expected + Received - blog/[id].tsx: 1b234bk12b3 + Loading... ❯ test/e2e/react.test.ts:58:26
})

it('hmr - dynamic add /test route', async () => {
await page.goto(getUrl('/'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/'))

await copyFile(srcPath, distPath)

await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })
// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')

Check failure on line 72 in test/e2e/react.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16)

test/e2e/react.test.ts > react e2e test > hmr - dynamic add /test route

AssertionError: expected 'Loading...' to be 'this is test file' // Object.is equality - Expected + Received - this is test file + Loading... ❯ test/e2e/react.test.ts:72:26

Check failure on line 72 in test/e2e/react.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

test/e2e/react.test.ts > react e2e test > hmr - dynamic add /test route

AssertionError: expected 'Loading...' to be 'this is test file' // Object.is equality - Expected + Received - this is test file + Loading... ❯ test/e2e/react.test.ts:72:26
Expand Down
17 changes: 10 additions & 7 deletions test/e2e/solid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,44 @@ describe('solid e2e test', () => {
const getUrl = (path: string) => `http://localhost:${server.config.server.port}${path}`

it('/blog/today have content', async () => {
await page.goto(getUrl('/blog/today'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/blog/today'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today/index.tsx')

Check failure on line 41 in test/e2e/solid.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16)

test/e2e/solid.test.ts > solid e2e test > /blog/today have content

AssertionError: expected '' to be 'blog/today/index.tsx' // Object.is equality - Expected + Received - blog/today/index.tsx ❯ test/e2e/solid.test.ts:41:26
})

it('/blog/today/xxx - nested cache all', async () => {
await page.goto(getUrl('/blog/today/xxx'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/blog/today/xxx'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today ...all route')
})

it('/xxx/xxx - cache all route', async () => {
await page.goto(getUrl('/xxx/xxx'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/xxx/xxx'))
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('...all route')

Check failure on line 53 in test/e2e/solid.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16)

test/e2e/solid.test.ts > solid e2e test > /xxx/xxx - cache all route

AssertionError: expected '' to be '...all route' // Object.is equality - Expected + Received - ...all route ❯ test/e2e/solid.test.ts:53:26

Check failure on line 53 in test/e2e/solid.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20)

test/e2e/solid.test.ts > solid e2e test > /xxx/xxx - cache all route

AssertionError: expected '' to be '...all route' // Object.is equality - Expected + Received - ...all route ❯ test/e2e/solid.test.ts:53:26
})

it('/about/1b234bk12b3/more deep nested dynamic route', async () => {
await page.goto(getUrl('/about/1b234bk12b3/more'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/about/1b234bk12b3/more'))
const text = await page.locator('div.deep-more').textContent()
expect(text?.trim()).toBe('deep nested: about/[id]/more.tsx')
})

it('/features/dashboard custom routes folder', async () => {
await page.goto(getUrl('/features/dashboard'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/features/dashboard'))
const text = await page.locator('body > div > p >> nth=0').textContent()
expect(text?.trim()).toBe('features/dashboard/pages/dashboard.tsx')
})

it('hmr - dynamic add /test route', async () => {
await page.goto(getUrl('/'), { waitUntil: 'networkidle' })
await page.goto(getUrl('/'))

await copyFile(srcPath, distPath)

await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })
// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ describe('vue e2e test', () => {

await copyFile(srcPath, distPath)

await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })
// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')
Expand Down

0 comments on commit 196902d

Please sign in to comment.