-
Notifications
You must be signed in to change notification settings - Fork 6k
dev(testing): add jest-playwright and reduce flakiness of e2e tests #3016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b4193b8
feat: add jest-playwright and packages
jsjoeio 3db1984
chore: add eslint plugin for jest-playwright
jsjoeio 6b3db06
feat: add new e2e test to test browser
jsjoeio bd55cb9
refactor: move test dir to jest e2e config
jsjoeio 1782f2a
refactor: rename e2e test to loginPage
jsjoeio 4b703cb
refactor: e2e tests based on jest-playwright
jsjoeio 51010e7
feat: add test for globalSetup
jsjoeio c666b47
refactor: globalSetup and create cookie manually
jsjoeio fd69f2d
refactor: logout test
jsjoeio 32d0fb0
refactor: add --runInBand to e2e test script
jsjoeio b1ea47c
chore: remove --home from test-e2e script
jsjoeio 03f7309
feat: add --log trace for running cs in ci
jsjoeio f241e38
chore: fix typo in extensionDownloader
jsjoeio dd80eed
feat: add logger to tests
jsjoeio ad0f12e
refactor: check for editor consistently in tests
jsjoeio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// <reference types="jest-playwright-preset" /> | ||
|
||
// This test is for nothing more than to make sure | ||
// tests are running in multiple browsers | ||
describe("Browser gutcheck", () => { | ||
beforeEach(async () => { | ||
await jestPlaywright.resetBrowser({ | ||
logger: { | ||
isEnabled: (name) => name === "browser", | ||
log: (name, severity, message, args) => console.log(`${name} ${message}`), | ||
}, | ||
}) | ||
}) | ||
|
||
test("should display correct browser based on userAgent", async () => { | ||
const displayNames = { | ||
chromium: "Chrome", | ||
firefox: "Firefox", | ||
webkit: "Safari", | ||
} | ||
const userAgent = await page.evaluate("navigator.userAgent") | ||
|
||
if (browserName === "chromium") { | ||
expect(userAgent).toContain(displayNames[browserName]) | ||
} | ||
|
||
if (browserName === "firefox") { | ||
expect(userAgent).toContain(displayNames[browserName]) | ||
} | ||
|
||
if (browserName === "webkit") { | ||
expect(userAgent).toContain(displayNames[browserName]) | ||
} | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference types="jest-playwright-preset" /> | ||
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants" | ||
|
||
// This test is to make sure the globalSetup works as expected | ||
// meaning globalSetup ran and stored the storageState in STORAGE | ||
describe("globalSetup", () => { | ||
beforeEach(async () => { | ||
// Create a new context with the saved storage state | ||
// so we don't have to logged in | ||
const storageState = JSON.parse(STORAGE) || {} | ||
await jestPlaywright.resetContext({ | ||
storageState, | ||
}) | ||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) | ||
}) | ||
|
||
it("should keep us logged in using the storageState", async () => { | ||
// Make sure the editor actually loaded | ||
expect(await page.isVisible("div.monaco-workbench")) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
import { chromium, Page, Browser, BrowserContext } from "playwright" | ||
/// <reference types="jest-playwright-preset" /> | ||
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants" | ||
|
||
describe("login", () => { | ||
let browser: Browser | ||
let page: Page | ||
let context: BrowserContext | ||
|
||
beforeAll(async () => { | ||
browser = await chromium.launch() | ||
context = await browser.newContext() | ||
}) | ||
|
||
afterAll(async () => { | ||
await browser.close() | ||
}) | ||
|
||
beforeEach(async () => { | ||
page = await context.newPage() | ||
}) | ||
|
||
afterEach(async () => { | ||
await page.close() | ||
// Remove password from local storage | ||
await context.clearCookies() | ||
await jestPlaywright.resetBrowser() | ||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) | ||
}) | ||
|
||
it("should be able to login", async () => { | ||
await page.goto(CODE_SERVER_ADDRESS) | ||
// Type in password | ||
await page.fill(".password", PASSWORD) | ||
// Click the submit button and login | ||
await page.click(".submit") | ||
// See the editor | ||
const codeServerEditor = await page.isVisible(".monaco-workbench") | ||
expect(codeServerEditor).toBeTruthy() | ||
await page.waitForLoadState("networkidle") | ||
// Make sure the editor actually loaded | ||
expect(await page.isVisible("div.monaco-workbench")) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference types="jest-playwright-preset" /> | ||
|
||
import { CODE_SERVER_ADDRESS } from "../utils/constants" | ||
|
||
describe("login page", () => { | ||
beforeEach(async () => { | ||
await jestPlaywright.resetContext({ | ||
logger: { | ||
isEnabled: (name, severity) => name === "browser", | ||
log: (name, severity, message, args) => console.log(`${name} ${message}`), | ||
}, | ||
}) | ||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) | ||
}) | ||
|
||
it("should see the login page", async () => { | ||
// It should send us to the login page | ||
expect(await page.title()).toBe("code-server login") | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.