File tree Expand file tree Collapse file tree 6 files changed +5195
-106
lines changed
02.raw-react/01.solution.elements Expand file tree Collapse file tree 6 files changed +5195
-106
lines changed Original file line number Diff line number Diff line change
1
+ import { expect , testStep } from '@epic-web/workshop-utils/test'
2
+
3
+ await testStep ( 'Hello is rendered to the DOM' , ( ) => {
4
+ const rootElement = document . getElementById ( 'root' )
5
+ expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
+
7
+ const element = rootElement ! . querySelector ( '.container' )
8
+ expect ( element , 'element not found' ) . to . be . instanceOf ( HTMLElement )
9
+
10
+ expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
+ 'Hello World' ,
12
+ )
13
+ } )
Original file line number Diff line number Diff line change
1
+ import { expect , testStep } from '@epic-web/workshop-utils/test'
2
+
3
+ await testStep ( 'Hello is rendered to the DOM' , ( ) => {
4
+ const rootElement = document . getElementById ( 'root' )
5
+ expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
+
7
+ const element = rootElement ! . querySelector ( '.container' )
8
+ expect ( element , 'element not found' ) . to . be . instanceOf ( HTMLElement )
9
+
10
+ expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
+ 'Hello World' ,
12
+ )
13
+ } )
14
+
15
+ await testStep ( 'root element is not in the HTML' , async ( ) => {
16
+ const response = await fetch ( location . href )
17
+ const text = await response . text ( )
18
+ const node = document . createElement ( 'div' )
19
+ node . innerHTML = text
20
+ expect (
21
+ node . querySelector ( '#root' ) ,
22
+ 'root element found in the HTML when it should not be' ,
23
+ ) . to . be . null
24
+ } )
Original file line number Diff line number Diff line change
1
+ import { expect , testStep } from '@epic-web/workshop-utils/test'
2
+
3
+ await testStep ( 'Hello is rendered to the DOM' , ( ) => {
4
+ const rootElement = document . getElementById ( 'root' )
5
+ expect ( rootElement , 'root element not found' ) . to . be . instanceOf ( HTMLElement )
6
+
7
+ const element = rootElement ! . querySelector ( '.container' )
8
+ expect ( element , 'element not found' ) . to . be . instanceOf ( HTMLElement )
9
+
10
+ expect ( element ! . textContent , 'element text is not correct' ) . to . equal (
11
+ 'Hello World' ,
12
+ )
13
+ } )
14
+
15
+ await testStep ( 'The DOM element is created by React' , ( ) => {
16
+ const element = document . querySelector ( '#root .container' )
17
+ expect ( element , 'element not found' ) . to . be . instanceOf ( HTMLElement )
18
+ if ( ! element ) return
19
+
20
+ const reactKeys = Object . keys ( element ) . filter ( key =>
21
+ key . startsWith ( '__react' ) ,
22
+ )
23
+ expect (
24
+ reactKeys . length ,
25
+ 'element was not created by React' ,
26
+ ) . to . be . greaterThan ( 0 )
27
+ } )
You can’t perform that action at this time.
0 commit comments