diff --git a/app/components/BrowserTests.js b/app/components/BrowserTests.js
new file mode 100644
index 0000000..4e11da3
--- /dev/null
+++ b/app/components/BrowserTests.js
@@ -0,0 +1,33 @@
+import React, { Component } from 'react'
+import { Button } from 'stardust'
+import autobind from 'autobind-decorator'
+
+import browserTest from '../content/lib/browser/runBrowserTest'
+
+const initialState = { status: null, err: null, stdout: null, stderr: null }
+
+export default class BrowserTests extends Component {
+ state = initialState
+
+ @autobind
+ testYahoo() {
+ this.setState({ ...initialState, status: '...running' })
+
+ browserTest('yahoo')
+ .then(res => {
+ this.setState({ ...res, status: 'passed' })
+ })
+ .catch(err => {
+ this.setState({ ...err, status: 'failed' })
+ })
+ }
+
+ render() {
+ return (
+
+
+
{JSON.stringify(this.state, null, 2)}
+
+ )
+ }
+}
diff --git a/app/containers/App.js b/app/containers/App.js
index 0b719b5..8045a22 100644
--- a/app/containers/App.js
+++ b/app/containers/App.js
@@ -20,6 +20,9 @@ export default class App extends Component {
Assignments
+
+ Browser Tests
+
Profile
diff --git a/app/containers/BrowserTestsPage.js b/app/containers/BrowserTestsPage.js
new file mode 100644
index 0000000..04972ae
--- /dev/null
+++ b/app/containers/BrowserTestsPage.js
@@ -0,0 +1,10 @@
+import React, { Component } from 'react'
+import BrowserTests from '../components/BrowserTests'
+
+export default class AssignmentsPage extends Component {
+ render() {
+ return (
+
+ )
+ }
+}
diff --git a/app/content/lib/browser/runBrowserTest.js b/app/content/lib/browser/runBrowserTest.js
new file mode 100644
index 0000000..77b3182
--- /dev/null
+++ b/app/content/lib/browser/runBrowserTest.js
@@ -0,0 +1,14 @@
+import cp from 'child_process'
+import Promise from 'bluebird'
+
+const runNightmare = (testPath) => new Promise((resolve, reject) => {
+ cp.execFile(`node`, [`app/content/lib/browser/${testPath}.js`], (err, stdout, stderr) => {
+ if (err) {
+ reject({ err, stdout, stderr })
+ } else {
+ resolve({ err, stdout, stderr })
+ }
+ })
+})
+
+export default runNightmare
diff --git a/app/content/lib/browser/yahoo.js b/app/content/lib/browser/yahoo.js
new file mode 100644
index 0000000..af8d1b1
--- /dev/null
+++ b/app/content/lib/browser/yahoo.js
@@ -0,0 +1,11 @@
+import Nightmare from 'nightmare'
+const nightmare = Nightmare({ show: true })
+
+nightmare
+ .goto('http://yahoo.com')
+ .type('input[title="Search"]', 'github nightmare')
+ .click('#uh-search-button')
+ .wait('#main')
+ .evaluate(() => document.querySelector('#main .searchCenterMiddle li a').href)
+ .end()
+ .then((x) => console.log(x))
diff --git a/app/routes.js b/app/routes.js
index d658263..d9c5ca0 100644
--- a/app/routes.js
+++ b/app/routes.js
@@ -4,6 +4,7 @@ import App from './containers/App'
import HomePage from './containers/HomePage'
import CounterPage from './containers/CounterPage'
import AssignmentsPage from './containers/AssignmentsPage'
+import BrowserTestsPage from './containers/BrowserTestsPage'
import ProfilePage from './containers/ProfilePage'
export default (
@@ -11,6 +12,7 @@ export default (
+
)
diff --git a/package.json b/package.json
index ee66dbc..576b1dc 100644
--- a/package.json
+++ b/package.json
@@ -107,6 +107,7 @@
"highlight.js": "^9.2.0",
"invariant": "^2.2.0",
"jquery": "^2.2.1",
+ "nightmare": "^2.2.0",
"react": "^0.14.2",
"react-dom": "^0.14.2",
"react-markdown": "^2.1.0",