File tree Expand file tree Collapse file tree 16 files changed +199
-84
lines changed
02.solution.interpolation Expand file tree Collapse file tree 16 files changed +199
-84
lines changed Original file line number Diff line number Diff line change
1
+ import { defineConfig , devices } from '@playwright/test'
2
+
3
+ const PORT = process . env . PORT || '5639'
4
+
5
+ export default defineConfig ( {
6
+ reporter : 'html' ,
7
+ use : {
8
+ baseURL : `http://localhost:${ PORT } /` ,
9
+ trace : 'retain-on-failure' ,
10
+ } ,
11
+
12
+ projects : [
13
+ {
14
+ name : 'chromium' ,
15
+ use : { ...devices [ 'Desktop Chrome' ] } ,
16
+ } ,
17
+ ] ,
18
+
19
+ webServer : {
20
+ command : 'cd .. && npm start' ,
21
+ port : Number ( PORT ) ,
22
+ reuseExistingServer : ! process . env . CI ,
23
+ stdout : 'pipe' ,
24
+ stderr : 'pipe' ,
25
+ env : { PORT } ,
26
+ } ,
27
+ } )
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
4
4
const rootElement = document . getElementById ( 'root' )
5
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
6
7
- const element = rootElement ! . querySelector ( '.container' )
8
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
9
17
10
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
4
4
const rootElement = document . getElementById ( 'root' )
5
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
6
7
- const element = rootElement ! . querySelector ( '.container' )
8
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
9
17
10
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
4
4
const rootElement = document . getElementById ( 'root' )
5
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
6
7
- const element = rootElement ! . querySelector ( '.container' )
8
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
9
17
10
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
4
4
const rootElement = document . getElementById ( 'root' )
5
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
6
if ( ! rootElement ) return
7
7
8
- const element = rootElement . querySelector ( '.container' )
9
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
8
+ const element = await dtl . waitFor (
9
+ ( ) => {
10
+ const element = rootElement ! . querySelector ( '.container' )
11
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
12
+ HTMLElement ,
13
+ )
14
+ return element
15
+ } ,
16
+ { timeout : 5000 } ,
17
+ )
18
+
10
19
if ( ! element ) return
11
20
12
21
if ( element . textContent === 'HelloWorld' ) {
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- await testStep ( 'Proper elements are rendered to the DOM' , ( ) => {
3
+ await testStep ( 'Proper elements are rendered to the DOM' , async ( ) => {
4
4
const rootElement = document . getElementById ( 'root' )
5
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
6
if ( ! rootElement ) return
7
7
8
- const element = rootElement . querySelector ( '.container' )
9
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
8
+ const element = await dtl . waitFor (
9
+ ( ) => {
10
+ const element = rootElement ! . querySelector ( '.container' )
11
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
12
+ HTMLElement ,
13
+ )
14
+ return element
15
+ } ,
16
+ { timeout : 5000 } ,
17
+ )
18
+
10
19
if ( ! element ) return
11
20
12
21
const p = element . querySelector ( 'p' )
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- // wait for babel to compile and evaluate the JSX
4
- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
5
-
6
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
7
4
const rootElement = document . getElementById ( 'root' )
8
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
9
6
10
- const element = rootElement ! . querySelector ( '.container' )
11
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
12
17
13
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
14
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- // wait for babel to compile and evaluate the JSX
4
- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
5
-
6
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
7
4
const rootElement = document . getElementById ( 'root' )
8
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
9
6
10
- const element = rootElement ! . querySelector ( '.container' )
11
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
12
17
13
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
14
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- // wait for babel to compile and evaluate the JSX
4
- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
5
-
6
- await testStep ( '"Hello World" is rendered to the DOM' , ( ) => {
3
+ await testStep ( '"Hello World" is rendered to the DOM' , async ( ) => {
7
4
const rootElement = document . getElementById ( 'root' )
8
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
9
6
10
- const element = rootElement ! . querySelector ( '.container' )
11
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
7
+ const element = await dtl . waitFor (
8
+ async ( ) => {
9
+ const element = rootElement ! . querySelector ( '.container' )
10
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
11
+ HTMLElement ,
12
+ )
13
+ return element
14
+ } ,
15
+ { timeout : 5000 } ,
16
+ )
12
17
13
18
expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
14
19
'Hello World' ,
Original file line number Diff line number Diff line change 1
- import { expect , testStep } from '@epic-web/workshop-utils/test'
1
+ import { expect , testStep , dtl } from '@epic-web/workshop-utils/test'
2
2
3
- // wait for babel to compile and evaluate the JSX
4
- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
5
-
6
- await testStep ( 'Proper elements are rendered to the DOM' , ( ) => {
3
+ await testStep ( 'Proper elements are rendered to the DOM' , async ( ) => {
7
4
const rootElement = document . getElementById ( 'root' )
8
5
expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
9
6
if ( ! rootElement ) return
10
7
11
- const element = rootElement . querySelector ( '.container' )
12
- expect ( element , 'container element not found' ) . to . be . instanceOf ( HTMLElement )
8
+ const element = await dtl . waitFor (
9
+ ( ) => {
10
+ const element = rootElement ! . querySelector ( '.container' )
11
+ expect ( element , 'container element not found' ) . to . be . instanceOf (
12
+ HTMLElement ,
13
+ )
14
+ return element
15
+ } ,
16
+ { timeout : 5000 } ,
17
+ )
18
+
13
19
if ( ! element ) return
14
20
15
21
const p = element . querySelector ( 'p' )
You can’t perform that action at this time.
0 commit comments