File tree 14 files changed +171
-84
lines changed
02.solution.interpolation
14 files changed +171
-84
lines changed 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' )
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
8
const element = rootElement
12
9
13
- const p = element . querySelector ( 'p' )
14
- expect ( p , '<p> not found' ) . to . be . instanceOf ( HTMLElement )
10
+ const p = await dtl . waitFor (
11
+ async ( ) => {
12
+ const p = element . querySelector ( 'p' )
13
+ expect ( p , '<p> not found' ) . to . be . instanceOf ( HTMLElement )
14
+ return p
15
+ } ,
16
+ { timeout : 5000 } ,
17
+ )
18
+
15
19
const ul = element . querySelector ( 'ul' )
16
20
expect ( ul , '<ul> not found' ) . to . be . instanceOf ( HTMLElement )
17
21
expect ( ul ) . to . have . class ( 'sams-food' )
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 messages = Array . from ( element . querySelectorAll ( '.message' ) )
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 messages = Array . from ( element . querySelectorAll ( '.message' ) )
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 messages = Array . from ( element . querySelectorAll ( '.message' ) )
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
8
const element = rootElement
12
9
13
- const h1 = element . querySelector ( 'h1' )
14
- expect ( h1 , 'h1 not found' ) . to . be . instanceOf ( HTMLElement )
15
- expect ( h1 ! . textContent ) . to . equal ( 'Calculator' )
10
+ await dtl . waitFor (
11
+ ( ) => {
12
+ const h1 = element . querySelector ( 'h1' )
13
+ expect ( h1 , 'h1 not found' ) . to . be . instanceOf ( HTMLElement )
14
+ expect ( h1 ! . textContent ) . to . equal ( 'Calculator' )
15
+ } ,
16
+ { timeout : 5000 } ,
17
+ )
16
18
17
19
const codeElements = Array . from ( element . querySelectorAll ( 'code' ) )
18
20
expect ( codeElements , 'code elements not found' ) . to . have . length ( 4 )
You can’t perform that action at this time.
0 commit comments