Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using zombie.js version 4.1.0 will not work in Chapter 5 #38

Open
michel-cliqz opened this issue Aug 28, 2015 · 13 comments
Open

Using zombie.js version 4.1.0 will not work in Chapter 5 #38

michel-cliqz opened this issue Aug 28, 2015 · 13 comments

Comments

@michel-cliqz
Copy link

@michel-cliqz michel-cliqz commented Aug 28, 2015

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 (assaf/zombie#909) and thus I installed 4.0.8.

@BradlySharpe
Copy link

@BradlySharpe BradlySharpe commented Sep 8, 2015

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"
}
@thepreacher
Copy link

@thepreacher thepreacher commented Jan 7, 2016

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 zombie@3.1.1 however the github code uses zombie@2.0.0-alpha31. Please which one should one use?

@marcdavies87
Copy link

@marcdavies87 marcdavies87 commented Jan 18, 2016

I am also having this issue and when I try to install npm install --save-dev zombie@3.1.1 I get the following:

npm ERR! contextify@0.1.15 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the contextify@0.1.15 install script 'node-gyp rebuild'.

Could do with some pointers here as I am struggling to progress part this bit.

@marcdavies87
Copy link

@marcdavies87 marcdavies87 commented Jan 18, 2016

On top of that when I go to us jshint I get the following:
jshint: command not found

@EthanRBrown
Copy link
Owner

@EthanRBrown EthanRBrown commented Jan 19, 2016

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.

@estevanmaito
Copy link

@estevanmaito estevanmaito commented Jan 23, 2016

Hey @EthanRBrown

I've made a PR (estevanmaito/zombie@5584faa) that solves this problem.

I've already changed history.js locally and it works!

@norain2050
Copy link

@norain2050 norain2050 commented May 4, 2016

Hey @estevanmaito
I use the way (estevanmaito/zombie@5584faa)estevanmaito/zombie@5584faa
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

  1. 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)
@nikolaysalinder
Copy link

@nikolaysalinder nikolaysalinder commented Jan 13, 2017

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 nikolaysalinder/Meadowlark-Travel@8a90f15

@ChrisHird
Copy link

@ChrisHird ChrisHird commented Mar 7, 2017

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.

@EthanRBrown
Copy link
Owner

@EthanRBrown EthanRBrown commented Mar 7, 2017

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!

@venoel
Copy link

@venoel venoel commented Mar 9, 2018

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.

@venoel
Copy link

@venoel venoel commented Mar 9, 2018

It seems document.referrer is empty when run Zombie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.