Skip to content

Commit 78d5be6

Browse files
authored
test: fix auth e2e test suite flakiness (#14655)
The `"richText field should should not be readOnly in create first user view"` test was expecting no user to exist. However, the previous test added a user, and the test suite was not reset in between tests. The only way this test passed was after waiting to retry, during which the database was reset. This test consistently fails at least one time. Additionally, every time the auth test suite starts up, it would spam the console with errors, as we were not waiting for compilation to be done. Example: https://github.com/payloadcms/payload/actions/runs/19444977200/job/55637794191 Both issues are fixed in this PR.
1 parent ab03163 commit 78d5be6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/auth/e2e.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const dirname = path.dirname(filename)
3030

3131
let payload: PayloadTestSDK<Config>
3232

33-
const { beforeAll, afterAll, describe } = test
33+
const { beforeAll, beforeEach, afterAll, describe } = test
3434

3535
const headers = {
3636
'Content-Type': 'application/json',
@@ -52,18 +52,18 @@ describe('Auth', () => {
5252
context = await browser.newContext()
5353
page = await context.newPage()
5454
initPageConsoleErrorCatch(page)
55+
56+
await ensureCompilationIsDone({ page, serverURL, noAutoLogin: true })
5557
})
5658

5759
describe('create first user', () => {
58-
beforeAll(async () => {
60+
beforeEach(async () => {
5961
await reInitializeDB({
6062
serverURL,
6163
snapshotKey: 'create-first-user',
6264
deleteOnly: true,
6365
})
6466

65-
await ensureCompilationIsDone({ page, serverURL, noAutoLogin: true })
66-
6767
await payload.delete({
6868
collection: slug,
6969
where: {
@@ -168,8 +168,6 @@ describe('Auth', () => {
168168
deleteOnly: false,
169169
})
170170

171-
await ensureCompilationIsDone({ page, serverURL, noAutoLogin: true })
172-
173171
await login({ page, serverURL })
174172
})
175173

0 commit comments

Comments
 (0)