-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tutorial to use npx babel-node for a better developer experience
- Loading branch information
1 parent
1d09638
commit bf663fc
Showing
6 changed files
with
165 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
Feature: Renders without Crashing | ||
Everybody wants to know if my React App can render without crashing | ||
Feature: App Displays Learn React | ||
Everybody wants to know if my React Component App can display the words: Learn React | ||
|
||
Scenario: Render App | ||
Given the DOM | ||
When I render a React component called: App | ||
Then my app should have rendered without crashing | ||
|
||
Scenario: Shallow Render App | ||
Scenario: Shallow Render | ||
Given the DOM | ||
When I shallow render a React component called: App | ||
Then my app should have rendered without crashing | ||
And my app should contain the words: Learn React | ||
Then my app should contain the words: Learn React |
20 changes: 5 additions & 15 deletions
20
step_definitions/stepdefs.js → features/step_definitions/stepdefs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,26 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from '../../transpiled/App'; | ||
import App from '../../src/App'; | ||
import { configure } from 'enzyme'; | ||
import { shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { shallow, mount, render} from 'enzyme'; | ||
|
||
const assert = require('assert'); | ||
const { Given, When, Then } = require('cucumber'); | ||
const { JSDOM } = require('jsdom'); | ||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>'); | ||
const { window } = jsdom; | ||
|
||
// Configures Enzyme Adapter | ||
configure({ adapter: new Adapter() }); | ||
|
||
Given('the DOM', function () { | ||
const { JSDOM } = require('jsdom'); | ||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>'); | ||
const { window } = jsdom; | ||
global.window = window; | ||
global.document = window.document; | ||
}); | ||
|
||
When('I render a React component called: App', function () { | ||
this.div = document.createElement('div'); | ||
ReactDOM.render(<App />, this.div); | ||
ReactDOM.unmountComponentAtNode(this.div); | ||
}); | ||
|
||
When('I shallow render a React component called: App', function () { | ||
this.wrapper = shallow(<App />); | ||
}); | ||
|
||
Then('my app should have rendered without crashing', function () {}); | ||
|
||
Then('my app should contain the words: Learn React', function () { | ||
assert(this.wrapper.contains('Learn React')); | ||
}); |
Oops, something went wrong.