Last active
August 29, 2015 14:03
-
-
Save twada/a97ef2605f5e4535c479 to your computer and use it in GitHub Desktop.
zombie.js の browser.assert を power-assert 化する試み(試してはいない)
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
var empower = require('empower'); | |
var formatter = require('power-assert-formatter'); | |
module.exports = function empowerZombie (browser) { | |
empower(browser.assert, formatter(), { | |
destructive: true, | |
modifyMessageOnRethrow: true, | |
saveContextOnRethrow: true, | |
patterns: [ | |
'browser.assert.redirected([message])', | |
'browser.assert.success([message])', | |
'browser.assert.attribute(selection, name, expected, [message])', | |
'browser.assert.className(selection, className, [message])', | |
'browser.assert.cookie(identifier, expected, [message])', | |
'browser.assert.element(selection, [message])', | |
'browser.assert.elements(selection, count, [message])', | |
'browser.assert.evaluate(expression, expected, [message])', | |
'browser.assert.global(name, expected, [message])', | |
'browser.assert.hasClass(selection, className, [message])', | |
'browser.assert.hasFocus(selection, [message])', | |
'browser.assert.hasNoClass(selection, className, [message])', | |
'browser.assert.input(selection, expected, [message])', | |
'browser.assert.link(selection, text, url, [message])', | |
'browser.assert.status(code, [message])', | |
'browser.assert.style(selection, style, expected, [message])', | |
'browser.assert.text(selection, expected, [message])', | |
'browser.assert.url(url, [message])' | |
] | |
}); | |
}; |
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
var Browser = require("zombie"); | |
var assert = require("power-assert"); | |
var empowerZombieBrowser = require("../empowerZombieBrowser"); | |
Browser.localhost('example.com', 3000); | |
describe("testing example.com", function () { | |
var browser = new Browser(); | |
empowerZombieBrowser(browser); | |
it("signup page", function () { | |
return browser.visit('/signup') | |
.then(function() { | |
// Fill email, password and submit form | |
browser.fill('email', 'zombie@underworld.dead'); | |
browser.fill('password', 'eat-the-living'); | |
return browser.pressButton('Sign Me Up!'); | |
}) | |
.then(function() { | |
// Form submitted, new page loaded. | |
browser.assert.success(); | |
browser.assert.text('title', 'Welcome To Brains Depot'); | |
}); | |
}); | |
}); |
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
--require ./powered-zombie-loader |
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
"name": "powered-zombie", | |
"version": "1.0.0", | |
"private": true, | |
"scripts": { | |
"test": "mocha --require ./powered-zombie-loader" | |
}, | |
"author": "Takuto Wada <takuto.wada@gmail.com>", | |
"license": "MIT", | |
"devDependencies": { | |
"empower": "^0.10.0", | |
"espower-loader": "^0.10.0", | |
"mocha": "^2.1.0", | |
"power-assert": "^0.10.2", | |
"power-assert-formatter": "^0.10.2", | |
"zombie": "^2.5.1" | |
} | |
} |
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
require('espower-loader')({ | |
cwd: process.cwd(), | |
pattern: 'test/**/*.js', | |
espowerOptions: { | |
destructive: false, | |
patterns: [ | |
'assert(value, [message])', | |
'assert.ok(value, [message])', | |
'assert.equal(actual, expected, [message])', | |
'assert.notEqual(actual, expected, [message])', | |
'assert.strictEqual(actual, expected, [message])', | |
'assert.notStrictEqual(actual, expected, [message])', | |
'assert.deepEqual(actual, expected, [message])', | |
'assert.notDeepEqual(actual, expected, [message])', | |
'browser.assert.redirected([message])', | |
'browser.assert.success([message])', | |
'browser.assert.attribute(selection, name, expected, [message])', | |
'browser.assert.className(selection, className, [message])', | |
'browser.assert.cookie(identifier, expected, [message])', | |
'browser.assert.element(selection, [message])', | |
'browser.assert.elements(selection, count, [message])', | |
'browser.assert.evaluate(expression, expected, [message])', | |
'browser.assert.global(name, expected, [message])', | |
'browser.assert.hasClass(selection, className, [message])', | |
'browser.assert.hasFocus(selection, [message])', | |
'browser.assert.hasNoClass(selection, className, [message])', | |
'browser.assert.input(selection, expected, [message])', | |
'browser.assert.link(selection, text, url, [message])', | |
'browser.assert.status(code, [message])', | |
'browser.assert.style(selection, style, expected, [message])', | |
'browser.assert.text(selection, expected, [message])', | |
'browser.assert.url(url, [message])' | |
] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🌟