Skip to content
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

test: fix e2e #310

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .vscode/launch.json
Expand Up @@ -15,6 +15,16 @@
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension samples/imba",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/samples/imba"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension In-Source Sample",
"type": "extensionHost",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -115,6 +115,7 @@
"@antfu/eslint-config": "^2.6.4",
"@babel/parser": "^7.20.15",
"@babel/types": "^7.20.7",
"@playwright/test": "^1.42.1",
"@rauschma/stringio": "^1.4.0",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
Expand All @@ -135,6 +136,7 @@
"chai": "^5.1.0",
"changelogithub": "^0.13.3",
"eslint": "^8.56.0",
"execa": "^8.0.1",
"fast-glob": "^3.3.2",
"flatted": "^3.2.9",
"fs-extra": "^10.0.1",
Expand All @@ -146,7 +148,6 @@
"mocha": "^10.3.0",
"pathe": "^1.1.2",
"picocolors": "^1.0.0",
"playwright": "^1.42.1",
"prompts": "^2.4.2",
"semver": "^7.3.5",
"strip-ansi": "^7.1.0",
Expand Down
17 changes: 14 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions test-e2e/basic.test.ts
@@ -1,4 +1,6 @@
import { beforeAll } from 'vitest'
import { execa } from 'execa'
import { expect } from '@playwright/test'
import { test } from './helper'

// Vitst extension doesn't work with CI flag
Expand All @@ -8,6 +10,7 @@ beforeAll(() => {
})

test('basic', async ({ launch }) => {
await execa('pnpm', ['i'], { cwd: './samples/e2e' })
const { page } = await launch({
workspacePath: './samples/e2e',
})
Expand All @@ -23,13 +26,14 @@ test('basic', async ({ launch }) => {
await page.getByRole('button', { name: 'Run Tests' }).click()

// check results
await page.locator(`[title*="pass.test.ts (Passed)"]`).click()
await page.locator(`[title*="fail.test.ts (Failed)"]`).click()
await page.locator(`[title*="mix.test.ts (Failed)"]`).click()
await page.locator(`[title*="3/7 tests passed"]`).click()
await expect(page.locator(`[title*="pass.test.ts (Passed)"]`)).toBeVisible()
await expect(page.locator(`[title*="fail.test.ts (Failed)"]`)).toBeVisible()
await expect(page.locator(`[title*="mix.test.ts (Failed)"]`)).toBeVisible()
await expect(page.locator(`[title*="3/7 tests passed"]`)).toBeVisible()
})

test('imba', async ({ launch }) => {
await execa('npm', ['i'], { cwd: './samples/imba' })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's the same issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, technically if samples/imba installed its own Vitest, then it's not testing against ecosystem-ci's Vitest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by

I'll also setup a wrapper script for ecosystem-ci, so we can tweak things while keeping the same script on ecosystem-ci repo.

const { page } = await launch({
workspacePath: './samples/imba',
})
Expand All @@ -46,7 +50,8 @@ test('imba', async ({ launch }) => {
await page.getByRole('button', { name: 'Run Tests' }).click()

// check results
await page.locator(`[title*="basic.test.imba (Passed)"]`).click()
await page.locator(`[title*="utils.imba (Passed)"]`).click()
await page.locator(`[title*="counter.imba (Failed)"]`).click()
await expect(page.locator(`[title*="5/7 tests passed"]`)).toBeVisible()
await expect(page.locator(`[title*="basic.test.imba (Passed)"]`)).toBeVisible()
await expect(page.locator(`[title*="utils.imba (Passed)"]`)).toBeVisible()
await expect(page.locator(`[title*="counter.imba (Failed)"]`)).toBeVisible()
})
4 changes: 2 additions & 2 deletions test-e2e/helper.ts
Expand Up @@ -2,8 +2,8 @@ import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { download } from '@vscode/test-electron'
import { _electron } from 'playwright'
import type { Page } from 'playwright'
import { _electron } from '@playwright/test'
import type { Page } from '@playwright/test'
import { test as baseTest } from 'vitest'

// based on
Expand Down
6 changes: 6 additions & 0 deletions test-e2e/vitest.config.ts
@@ -1,5 +1,11 @@
import { defineConfig } from 'vitest/config'

// to open playwright inspector either run with `PWDEBUG`
// PWDEBUG=1 pnpm test-e2e
//
// or use `page.pause` inside a test code
// await page.pase()

export default defineConfig({
test: {
// use Infinity on local for `page.pause()`
Expand Down