web-development-with-node-and-express
web-development-with-node-and-express copied to clipboard
Using zombie.js version 4.1.0 will not work in Chapter 5
On page 46 one needs to install zombie, this will, however, install version 4.1.0. 4.1.0 is for some reason not supported (https://github.com/assaf/zombie/issues/909) and thus I installed 4.0.8.
I had more issues with this section, it wouldn't work with 4.0.8 so I took the version from the package.json in the git repo and installed them.
"dependencies": {
"express": "^4.13.3",
"express-handlebars": "^2.0.1",
"chai": "~1.9.1"
},
"devDependencies": {
"mocha": "~1.20.1",
"zombie": "~2.0.0-alpha31"
}
I appreciate the challenge the author faces with regards to the fact that node.js is relatively new and depends on so many other modules to get an application working. Node it self and its dependencies are evolving so fast that, keeping your applications current is huge challenge.
I am also having the same issues as the original author and I've tried all sort of suggestions without success. I have spent two days now trying to find a fix. For a newbie this could be the difference between abandoning the book and following through to the end.
I would be most grateful if the authour could find some time to update the book and the code to current versions of depencies. For example I tried on my own to change code in tests-crosspage.js to match the current zombie.js version. However it looks like browser.clickLink in no longer available in the latest zombie.js and I'm now stuck on finding an equivalent method by reading the doc.
This is the reason why I bought the pdf version of the book because I anticipated, issues like these however I was hoping that any changes will be updated much more quickly in the pdf than the hard copy.
Thank you very much author for a good book, please try and update the code for us. After all what is the point of learning a skill using old packages only to find out later that you cannot use any on the current packages to solve problem.
EDIT: Ok so going through the source for zombie on github, particularly index.js, I realised clickLink is till available. I'm going to retype the code all over again. But the book recommends [email protected] however the github code uses [email protected]. Please which one should one use?
I am also having this issue and when I try to install npm install --save-dev [email protected] I get the following:
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
Could do with some pointers here as I am struggling to progress part this bit.
On top of that when I go to us jshint I get the following: jshint: command not found
Hello @marcdavies87 and @thepreacher! This is Ethan, the author (yes, I have a name!) I'm sorry you're having some issues with Zombie; I believe I will remove the dependence on Zombie in a future edition of the book as it has caused nothing but problems, especially with people on Windows.
The book is not about QA, and it's possible that I was over-reaching by trying to include a topic that could be a whole book itself in a single chapter. Certainly I will be trimming down this content, especially as it relates to Zombie, as I do not have the bandwidth to continually keep the code up-to-date: I have a full-time job, am finishing up grad school, and have just finished another book. Technologies in the Node space move very fast, and I am not making enough money from this book to keep everything up to date. I do welcome community solutions, and I am hoping to publish a second edition of this book in 2017, at which point I will thoroughly update everything.
I will say that all code in all chapters in the repo (with the version listed in package.json
: ~2.0.0-alpha31) work correctly and pass all tests in Linux (Ubuntu 14.04.02 LTS, Node 4.2.2, npm 2.14.7). I no longer have a Mac, so I cannot currently test the code on OS X, and I am aware that Zombie does not work in Windows (without considerable work), but I have stopped testing the repo in Windows. I have not tested or updated the code to work with Zombie versions past 2.0.
I would not beat your head forever against Zombie issues; it is only used for the cross-page tests, and unless you are a QA engineer (in which case you should be reading other books as well), I think you can disable or remove the cross-page tests and proceed without them.
Once again, I happily accept community fixes; it is unlikely I will have time to look into this thorny issue in more depth any time soon...perhaps spring break.
Hey @EthanRBrown
I've made a PR (https://github.com/estevanmaito/zombie/commit/5584faa980efe5809312983dcbd6697088793d55) that solves this problem.
I've already changed history.js locally and it works!
Hey @estevanmaito I use the way (estevanmaito/zombie@5584faa)https://github.com/estevanmaito/zombie/commit/5584faa980efe5809312983dcbd6697088793d55 but,it has no port:3000
like: (1)test3.js
` /**
- Created by xinyiba on 16/5/4. */ const Browser = require('zombie');
Browser.localhost('localhost', 3000);
describe('User visits test-crosspage ', function() {
const browser = new Browser();
const refers = 'http://localhost:3000/tours/hood-river';
before(function (done) {
browser.visit('/tours/hood-river',done);
});
describe('test the click',function(){
before(function(done){
browser.clickLink('#requestGroupRate',done);
});
it('test input',function(done){
browser.assert.success();
browser.assert.input('#referrer', refers);
});
});
}); `
(2) mocha -t 9999 -u bdd -R spec qa/test3.js
(3)bug 0 passing (2s) 1 failing
- User visits test-crosspage test the click test input:
AssertionError: 'http://localhost/tours/hood-river' deepEqual 'http://localhost:3000/tours/hood-river'
+ expected - actual
-http://localhost/tours/hood-river
+http://localhost:3000/tours/hood-river
at assertMatch (node_modules/zombie/lib/assert.js:24:212)
at Assert.input (node_modules/zombie/lib/assert.js:314:11)
at Context.<anonymous> (qa/test3.js:24:32)
Hi all! Tx Ethan for this cool book!! I'm from Russia and this book translated on russian. Now zombie work on windows but for correct working need to change qa/tests-crosspage.js like https://github.com/nikolaysalinder/Meadowlark-Travel/commit/8a90f15c9e0ae6def6b66fd554941377f7b58fb6
The problem appears to be with the use of chai.assert. When I updated the code to use the zombie browser.assert method it worked as it should have done. The updates suggested by @estevanmaito work other than he left one of the tests using the chai.assert method. Here is the completed test that I have ran on both IBM i (ppc64) and Linux (debian) with satisfactory results.
var Browser = require('zombie');
//var assert = require('chai').assert;
var browser;
suite('Cross-Page Tests', function(){
setup(function() {
browser = new Browser();
});
this.timeout(5000);
// this test fails on the assertion, checking the actual output says it should pass
test('requesting a group rate quote from hood river tour page should populate the referrer field', function(done) {
var referrer = 'http://sas4:8081/tours/hood-river';
browser.visit(referrer, function() {
browser.clickLink('.requestGroupRate', function() {
//assert(browser.field('referrer').value === referrer,"Not equal to referrer");
browser.assert.element('form input[name=referrer]',referrer);
done();
});
});
});
// this test fails on the assertion, checking the actual output says it should pass
test('requesting a group rate quote from oregan coast tour page should populate the referrer field', function(done) {
var referrer = 'http://sas4:8081/tours/oregan-coast';
browser.visit(referrer, function() {
browser.clickLink('.requestGroupRate', function() {
//assert(browser.field('referrer').value === referrer,"Not equal to referrer");
browser.assert.element('form input[name=referrer]',referrer);
done();
});
});
});
// this test passes but not sure it is actually making it real?
test('visiting the "request group rate" page directly should result in an empty referrer field', function(done) {
browser.visit('http://sas4:8081/tours/request-group-rate', function() {
//assert(browser.field('referrer').value === '',"Not set");
browser.assert.element('form input[name=referrer]','');
done();
});
});
});
I hope that helps those continuing to follow the book? So far so good.
Thanks everyone for the contributions! In the next edition of the book (which I'm working on now), I will be moving away from Zombie. It's still a useful testing tool, but I think it has caused more problems in this book than it has solved. Thanks again for reading!
I read book. I am on chapter 5.
And I struggle with Zombie. Sorry, but I think there are mistaken post above.
browser.assert.element
does not compare value of element, it just check is element exists.
So assert should be assert(browser.field('referrer').value === referrer);
But I think the problem is Zombie does not executes javascript
{{#section 'jquery'}}
<script>
$(document).ready(function(){
$('input[name="referrer"]').val(document.referrer);
});
</script>
{{/section}}
so $('input[name="referrer"]').val
leaves empty.
It seems document.referrer
is empty when run Zombie.
See here
https://github.com/assaf/zombie/pull/947/files/9b763ee167a8a6afd8af81a5167693bd22004dbf
this comment helped me https://stackoverflow.com/a/35952530/14818086
assert(browser.resources[0].request.headers._headers[0][1] === referrer);
Hello guys. The working solution is
------------------------------
var referrer = 'http://localhost:8080/tours/hood-river';
browser.visit(referrer, function(){
browser.clickLink('requestGroupRate', function(){
assert(browser.resources[0].request.headers._headers[0][1] === referrer);
done();
});
});