Skip to content

Commit c021450

Browse files
Running tests in browsers using Playwright (#572)
* 0 * adding playwright * playwright * lock * playwright * chromium * ci * browser * CI * changelog
1 parent 883ea52 commit c021450

24 files changed

+182
-21
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@
7979
{
8080
"run": "npx tsgo"
8181
},
82+
{
83+
"run": "npx playwright install --with-deps"
84+
},
85+
{
86+
"run": "npx playwright test --browser=chromium"
87+
},
88+
{
89+
"run": "npx playwright test --browser=firefox"
90+
},
91+
{
92+
"run": "npx playwright test --browser=webkit"
93+
},
8294
{
8395
"run": "npm pack"
8496
},
@@ -300,6 +312,18 @@
300312
{
301313
"run": "npx tsgo"
302314
},
315+
{
316+
"run": "npx playwright install --with-deps"
317+
},
318+
{
319+
"run": "npx playwright test --browser=chromium"
320+
},
321+
{
322+
"run": "npx playwright test --browser=firefox"
323+
},
324+
{
325+
"run": "npx playwright test --browser=webkit"
326+
},
303327
{
304328
"run": "npm pack"
305329
},
@@ -506,6 +530,18 @@
506530
{
507531
"run": "npx tsgo"
508532
},
533+
{
534+
"run": "npx playwright install --with-deps"
535+
},
536+
{
537+
"run": "npx playwright test --browser=chromium"
538+
},
539+
{
540+
"run": "npx playwright test --browser=firefox"
541+
},
542+
{
543+
"run": "npx playwright test --browser=webkit"
544+
},
509545
{
510546
"run": "npm pack"
511547
},
@@ -712,6 +748,18 @@
712748
{
713749
"run": "npx tsgo"
714750
},
751+
{
752+
"run": "npx playwright install --with-deps"
753+
},
754+
{
755+
"run": "npx playwright test --browser=chromium"
756+
},
757+
{
758+
"run": "npx playwright test --browser=firefox"
759+
},
760+
{
761+
"run": "npx playwright test --browser=webkit"
762+
},
715763
{
716764
"run": "npm pack"
717765
},
@@ -918,6 +966,18 @@
918966
{
919967
"run": "npx tsgo"
920968
},
969+
{
970+
"run": "npx playwright install --with-deps"
971+
},
972+
{
973+
"run": "npx playwright test --browser=chromium"
974+
},
975+
{
976+
"run": "npx playwright test --browser=firefox"
977+
},
978+
{
979+
"run": "npx playwright test --browser=webkit"
980+
},
921981
{
922982
"run": "npm pack"
923983
},
@@ -1130,6 +1190,18 @@
11301190
{
11311191
"run": "npx tsgo"
11321192
},
1193+
{
1194+
"run": "npx playwright install --with-deps"
1195+
},
1196+
{
1197+
"run": "npx playwright test --browser=chromium"
1198+
},
1199+
{
1200+
"run": "npx playwright test --browser=firefox"
1201+
},
1202+
{
1203+
"run": "npx playwright test --browser=webkit"
1204+
},
11331205
{
11341206
"run": "npm pack"
11351207
},

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bin/
116116
*.exp
117117
*.lib
118118

119-
# temoprary files
119+
# temporary files
120120
_result.*
121121

122122
# Rust
@@ -130,4 +130,5 @@ _*
130130
**/*.d.ts
131131
**/*.js
132132

133-
deno.lock
133+
deno.lock
134+
test-results/

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Running tests in browsers [PR 572](https://github.com/functionalscript/functionalscript/pull/572)
1011
- Generating a GitHub CI file [PR 569](https://github.com/functionalscript/functionalscript/pull/569)
1112
- New Nominal type that prohibits '<' operations in Type Script
1213
[PR 567](https://github.com/functionalscript/functionalscript/pull/567).

ci/module.f.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ const steps = (v: Os) => (a: Architecture): readonly Step[] => {
124124
...oldNode('22'),
125125
...node('24')([]),
126126
...node('25')([
127+
// TypeScript Preview
127128
{ run: 'npx tsgo' },
129+
// Playwright
130+
{ run: 'npx playwright install --with-deps' },
131+
...['chromium', 'firefox', 'webkit'].map(browser =>
132+
({ run: `npx playwright test --browser=${browser}` })),
133+
// publishing
128134
{ run: 'npm pack' },
129135
{ run: `npm install -g ${install(v)}` },
130136
{ run: 'fsc issues/demo/data/tree.json _tree.f.js' },

dev/tf/all.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ declare const Bun: object | undefined
99

1010
const isBun = typeof Bun !== 'undefined'
1111

12+
const isPlaywright = typeof process !== 'undefined' && process?.env?.PLAYWRIGHT_TEST !== undefined
13+
1214
//
1315

1416
type Awaitable<T> = Promise<T> | T
@@ -24,10 +26,19 @@ type CommonFramework = (name: string, f: TestFunc) => Awaitable<void>
2426
const createFramework = (fw: typeof nodeTest): CommonFramework =>
2527
(prefix, f) => fw.test(prefix, t => f((name, v) => t.test(name, v)))
2628

29+
// Bun doesn't support nested tests yet.
2730
const createBunFramework = (fw: typeof nodeTest): CommonFramework =>
2831
(prefix, f) => f((name, v) => fw.test(`${prefix}: ${name}`, v))
2932

30-
const framework = isBun ? createBunFramework(nodeTest) : createFramework(nodeTest)
33+
const createPlaywrihtFramework = async (): Promise<CommonFramework> => {
34+
const pwTest = (await import('@playwright/test')).test
35+
return (prefix, f) => f((name, v) => pwTest(`${prefix}: ${name}`, v))
36+
}
37+
38+
const framework: CommonFramework =
39+
isPlaywright ? await createPlaywrihtFramework() :
40+
isBun ? createBunFramework(nodeTest) :
41+
createFramework(nodeTest)
3142

3243
const parse = parseTestSet(io.tryCatch)
3344

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)