Skip to content

Commit

Permalink
wip: chrome test
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Nov 12, 2023
1 parent 61d25fa commit de86920
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions test/conductor/ChromeTestConductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { createTestRun } from '#src/conductor/TestRun'
import { ChromeTestConductor } from '#src/conductor/ChromeTestConductor'
import { getTestFunction } from './_helper'

let runnerModule = ''
beforeEach(async () => {
let fileServer: HttpFileServer
beforeAll(async () => {
const build = await rollup({
input: './src/runner/index.ts',
plugins: [
Expand All @@ -19,28 +19,32 @@ beforeEach(async () => {
],
})
const {output} = await build.generate({})
runnerModule = output[0].code
})
const runnerModule = output[0].code

async function setupConductor() {
const fileServer = new HttpFileServer(
fileServer = new HttpFileServer(
new FileProvider(import.meta.url, new Map([
['runner.js', Promise.resolve({content: runnerModule})],
])),
)
await fileServer.url
})
afterAll(() => fileServer.close())

async function setupConductor() {
const conductor = new ChromeTestConductor(`${String(await fileServer.url)}runner.js`)

afterThis(() => fileServer.close())
afterThis(() => conductor.close())

return {
fileServer,
conductor,
}
return {conductor}
}

test('launch browser', async () => {
const {conductor} = await setupConductor()
await conductor.browser
})

test('conduct test', async () => {
const { conductor, fileServer } = await setupConductor()
const {conductor} = await setupConductor()
fileServer.provider.files.set('some/test.js', Promise.resolve({content: `
test('some test', () => {});
test('failing test', () => { throw new Error('some error') });
Expand All @@ -62,7 +66,7 @@ test('conduct test', async () => {
})

test('abort test', async () => {
const { conductor, fileServer } = await setupConductor()
const { conductor } = await setupConductor()
fileServer.provider.files.set('some/test.js', Promise.resolve({content: `
test('some test', () => {});
test('aborted test', () => new Promise(r => setTimeout(r, 10000)));
Expand Down

0 comments on commit de86920

Please sign in to comment.