Last active
November 24, 2016 09:29
-
-
Save artemave/5b59c493d7f5d056d739a3a3e43f742c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { expect } from 'chai'; | |
| export default function(browser) { | |
| return browser.component({ | |
| fetchTODOsButton() { | |
| return this.find('button'); | |
| }, | |
| loadingBar() { | |
| return this.find('.loading', {text: 'Loading...'}); | |
| }, | |
| async expectTODOs(...expectedTodos) { | |
| var actualTodos = (await this.find('ul li').elements()) | |
| .map(e => e.innerText); | |
| expect(actualTodos.sort()).to.eql(expectedTodos.sort()); | |
| } | |
| }); | |
| }); |
This file contains hidden or 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
| import createBrowser from 'browser-monkey/create'; | |
| import pageHelper from './pageHelper'; | |
| var browser, page; | |
| beforeEach(() => { | |
| browser = createBrowser(document.body); | |
| page = pageHelper(browser); | |
| }); | |
| it('allows user to fetch todos', async () => { | |
| await page.fetchTODOsButton().click(); | |
| await page.loadingBar().shouldExist(); | |
| await page.expectTODOs('one', 'two'); | |
| }); |
This file contains hidden or 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
| import createBrowser from 'browser-monkey/create'; | |
| import pageHelper from './pageHelper'; | |
| var browser, page; | |
| beforeEach(() => { | |
| browser = createBrowser(document.body); | |
| page = pageHelper(browser); | |
| }); | |
| it('allows user to fetch todos', async () => { | |
| await page.fetchTODOsButton().click(); | |
| await page.loadingBar().shouldExist(); | |
| await page.expectTODOs('one', 'two'); | |
| }); |
This file contains hidden or 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
| import createBrowser from 'browser-monkey/create'; | |
| var browser; | |
| beforeEach(() => { | |
| browser = createBrowser(document.body); | |
| }); | |
| it('allows user to fetch todos', async () => { | |
| // click button | |
| await browser.find('button').click(); | |
| // observe "Loading..." | |
| await browser.find('.loading', {text: 'Loading...'}).shouldExist(); | |
| // collect results from DOM | |
| let actualTodos = (await browser.find('ul li').elements()) | |
| .map(e => e.innerText); | |
| // assert results | |
| expect(actualTodos.sort()).to.eql(['one', 'two'].sort()); | |
| }); |
This file contains hidden or 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
| module.exports = function(config) { | |
| config.set({ | |
| frameworks: ['browserify', 'mocha'], | |
| files: [ | |
| 'test/**/*Spec.js' | |
| ], | |
| preprocessors: { | |
| 'test/**/*.js': ['browserify'] | |
| }, | |
| browserify: { | |
| debug: true, | |
| transform: ['babelify'], | |
| extensions: ['.jsx'] | |
| }, | |
| }) | |
| } |
This file contains hidden or 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
| ... | |
| "scripts": { | |
| "test-karma": "karma start --single-run", | |
| "test-electron": "electron-mocha --renderer --compilers js:babel-core/register test/**/*Spec.js", | |
| "test-vdom": "mocha --compilers js:babel-core/register test/**/*Spec.js" | |
| }, | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment