Skip to content

Commit d1beac1

Browse files
committed
fix playwright tests
1 parent f4a50e7 commit d1beac1

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: start a server
4646
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
4747
- name: run chromium tests
48-
run: './bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
48+
run: 'BROWSER=chromium ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
4949
- name: run chromium with restart==browser tests
5050
run: 'BROWSER_RESTART=browser ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
5151
- name: run chromium with restart==session tests
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { createRequire } from 'module'
2+
import { fileURLToPath } from 'url'
3+
import { dirname } from 'path'
4+
const require = createRequire(import.meta.url)
5+
const { ClientFunction } = require('testcafe')
6+
const __filename = fileURLToPath(import.meta.url)
7+
const __dirname = dirname(__filename)
8+
9+
import assert from 'assert'
10+
import fs from 'fs'
11+
import path from 'path'
12+
import { getParamNames } from '../../utils.js'
13+
14+
const createTestFile = () => {
15+
assert(global.output_dir, 'global.output_dir must be set')
16+
17+
const testFile = path.join(global.output_dir, `${Date.now()}_test.js`)
18+
const testControllerHolderDir = __dirname.replace(/\\/g, '/')
19+
20+
fs.writeFileSync(
21+
testFile,
22+
`const testControllerHolder = require("${testControllerHolderDir}/testControllerHolder.cjs");\n\n
23+
fixture("fixture")\n
24+
test\n
25+
("test", testControllerHolder.capture)`,
26+
)
27+
28+
return testFile
29+
}
30+
31+
const mapError = testcafeErr => {
32+
if (!testcafeErr) return new Error('Unknown error')
33+
34+
const code = testcafeErr.code
35+
if (code && testcafeErr.callsite) {
36+
return testcafeErr
37+
}
38+
39+
const stack = testcafeErr.stack || testcafeErr.toString()
40+
const message = testcafeErr.message || testcafeErr.toString()
41+
const error = new Error(message)
42+
error.stack = stack
43+
return error
44+
}
45+
46+
const createClientFunction = clientFn => {
47+
const fnString = clientFn.toString()
48+
const params = getParamNames(clientFn)
49+
50+
return ClientFunction(fnString, { dependencies: {} })
51+
}
52+
53+
export { createTestFile, mapError, createClientFunction }

0 commit comments

Comments
 (0)