don't use base fixture
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect, Page } from '@playwright/test'
|
||||||
import { expect, Page } from '@playwright/test'
|
|
||||||
import {
|
import {
|
||||||
getUtils,
|
getUtils,
|
||||||
TEST_COLORS,
|
TEST_COLORS,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { EngineCommand } from 'lang/std/artifactGraph'
|
import { EngineCommand } from 'lang/std/artifactGraph'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { bracket } from 'lib/exampleKcl'
|
import { bracket } from 'lib/exampleKcl'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { KCL_DEFAULT_LENGTH } from 'lib/constants'
|
import { KCL_DEFAULT_LENGTH } from 'lib/constants'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
|
|
||||||
test.beforeEach(async ({ context, page }) => {
|
test.beforeEach(async ({ context, page }) => {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
import * as fs from 'fs'
|
|
||||||
import * as path from 'path'
|
|
||||||
import * as crypto from 'crypto'
|
|
||||||
import { test as baseTest } from '@playwright/test'
|
|
||||||
|
|
||||||
const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output')
|
|
||||||
|
|
||||||
export function generateUUID(): string {
|
|
||||||
return crypto.randomBytes(16).toString('hex')
|
|
||||||
}
|
|
||||||
|
|
||||||
export const test = baseTest.extend({
|
|
||||||
context: async ({ context }, use) => {
|
|
||||||
await context.addInitScript(() =>
|
|
||||||
window.addEventListener('beforeunload', () =>
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(window as any).collectIstanbulCoverage(
|
|
||||||
JSON.stringify((window as any).__coverage__)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await fs.promises.mkdir(istanbulCLIOutput, { recursive: true })
|
|
||||||
await context.exposeFunction(
|
|
||||||
'collectIstanbulCoverage',
|
|
||||||
(coverageJSON: string) => {
|
|
||||||
if (coverageJSON)
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(
|
|
||||||
istanbulCLIOutput,
|
|
||||||
`playwright_coverage_${generateUUID()}.json`
|
|
||||||
),
|
|
||||||
coverageJSON
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
await use(context)
|
|
||||||
for (const page of context.pages()) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
await page.evaluate(() =>
|
|
||||||
(window as any).collectIstanbulCoverage(
|
|
||||||
JSON.stringify((window as any).__coverage__)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export const expect = test.expect
|
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { bracket } from 'lib/exampleKcl'
|
import { bracket } from 'lib/exampleKcl'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect, Page } from '@playwright/test'
|
||||||
import { expect, Page } from '@playwright/test'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getMovementUtils,
|
getMovementUtils,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { secrets } from './secrets'
|
import { secrets } from './secrets'
|
||||||
import { Paths, doExport, getUtils } from './test-utils'
|
import { Paths, doExport, getUtils } from './test-utils'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { commonPoints, getUtils, setup, tearDown } from './test-utils'
|
import { commonPoints, getUtils, setup, tearDown } from './test-utils'
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ import {
|
|||||||
import { EngineCommand } from 'lang/std/artifactGraph'
|
import { EngineCommand } from 'lang/std/artifactGraph'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
import fsp from 'fs/promises'
|
import fsp from 'fs/promises'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
import pixelMatch from 'pixelmatch'
|
import pixelMatch from 'pixelmatch'
|
||||||
import { PNG } from 'pngjs'
|
import { PNG } from 'pngjs'
|
||||||
import { Protocol } from 'playwright-core/types/protocol'
|
import { Protocol } from 'playwright-core/types/protocol'
|
||||||
@ -17,6 +19,7 @@ import waitOn from 'wait-on'
|
|||||||
import { secrets } from './secrets'
|
import { secrets } from './secrets'
|
||||||
import { TEST_SETTINGS_KEY, TEST_SETTINGS } from './storageStates'
|
import { TEST_SETTINGS_KEY, TEST_SETTINGS } from './storageStates'
|
||||||
import * as TOML from '@iarna/toml'
|
import * as TOML from '@iarna/toml'
|
||||||
|
import { uuidv4 } from 'lib/utils'
|
||||||
|
|
||||||
type TestColor = [number, number, number]
|
type TestColor = [number, number, number]
|
||||||
export const TEST_COLORS = {
|
export const TEST_COLORS = {
|
||||||
@ -601,6 +604,16 @@ export async function tearDown(page: Page, testInfo: TestInfo) {
|
|||||||
uploadThroughput: -1,
|
uploadThroughput: -1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (process.env.GENERATE_PLAYWRIGHT_COVERAGE) {
|
||||||
|
for (const activePage of page.context().pages()) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
await activePage.evaluate(() =>
|
||||||
|
(window as any).collectIstanbulCoverage(
|
||||||
|
JSON.stringify((window as any).__coverage__)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
// It seems it's best to give the browser about 3s to close things
|
// It seems it's best to give the browser about 3s to close things
|
||||||
// It's not super reliable but we have no real other choice for now
|
// It's not super reliable but we have no real other choice for now
|
||||||
await page.waitForTimeout(3000)
|
await page.waitForTimeout(3000)
|
||||||
@ -626,6 +639,34 @@ export async function setup(context: BrowserContext, page: Page) {
|
|||||||
settings: TOML.stringify({ settings: TEST_SETTINGS }),
|
settings: TOML.stringify({ settings: TEST_SETTINGS }),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (process.env.GENERATE_PLAYWRIGHT_COVERAGE) {
|
||||||
|
await context.addInitScript(() =>
|
||||||
|
window.addEventListener('beforeunload', () =>
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(window as any).collectIstanbulCoverage(
|
||||||
|
JSON.stringify((window as any).__coverage__)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output')
|
||||||
|
await fsp.mkdir(istanbulCLIOutput, { recursive: true })
|
||||||
|
await context.exposeFunction(
|
||||||
|
'collectIstanbulCoverage',
|
||||||
|
(coverageJSON: string) => {
|
||||||
|
if (coverageJSON) {
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(
|
||||||
|
istanbulCLIOutput,
|
||||||
|
`playwright_coverage_${uuidv4()}.json`
|
||||||
|
),
|
||||||
|
coverageJSON
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// kill animations, speeds up tests and reduced flakiness
|
// kill animations, speeds up tests and reduced flakiness
|
||||||
await page.emulateMedia({ reducedMotion: 'reduce' })
|
await page.emulateMedia({ reducedMotion: 'reduce' })
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { EngineCommand } from 'lang/std/artifactGraph'
|
import { EngineCommand } from 'lang/std/artifactGraph'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown, TEST_COLORS } from './test-utils'
|
import { getUtils, setup, tearDown, TEST_COLORS } from './test-utils'
|
||||||
import { XOR } from 'lib/utils'
|
import { XOR } from 'lib/utils'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect, Page } from '@playwright/test'
|
||||||
import { expect, Page } from '@playwright/test'
|
|
||||||
|
|
||||||
import { deg, getUtils, setup, tearDown, wiggleMove } from './test-utils'
|
import { deg, getUtils, setup, tearDown, wiggleMove } from './test-utils'
|
||||||
import { LineInputsType } from 'lang/std/sketchcombos'
|
import { LineInputsType } from 'lang/std/sketchcombos'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import { commonPoints, getUtils, setup, tearDown } from './test-utils'
|
import { commonPoints, getUtils, setup, tearDown } from './test-utils'
|
||||||
import { Coords2d } from 'lang/std/sketch'
|
import { Coords2d } from 'lang/std/sketch'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, tearDown } from './test-utils'
|
||||||
import { SaveSettingsPayload } from 'lib/settings/settingsTypes'
|
import { SaveSettingsPayload } from 'lib/settings/settingsTypes'
|
||||||
import { TEST_SETTINGS_KEY, TEST_SETTINGS_CORRUPTED } from './storageStates'
|
import { TEST_SETTINGS_KEY, TEST_SETTINGS_CORRUPTED } from './storageStates'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { test } from './lib/base-fixture'
|
import { test, expect } from '@playwright/test'
|
||||||
import { expect } from '@playwright/test'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
doExport,
|
doExport,
|
||||||
|
Reference in New Issue
Block a user