Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zombie.js の browser.assert を power-assert 化する試み(試してはいない)
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])'
]
});
};
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');
});
});
});
--require ./powered-zombie-loader
"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"
}
}
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])'
]
}
});
@nishigori

This comment has been minimized.

Copy link

@nishigori nishigori commented Jun 27, 2014

🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment