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
Issues using with CasperJS #1112
Comments
@tgoldenberg I just gave capser-js a try with my next.js site. Was a simple test: start -> echo title -> click nav link (uses "Link" component) -> echo title. Worked fine. Link component uses Router.push, so that doesn't seem to be the problem. It's difficult to determine what your problem is without seeing your code. my package.json: {
"name": "test",
"scripts": {
"test": "node_modules/casperjs/bin/casperjs index.js"
},
"devDependencies": {
"casperjs": "^1.1.3",
"phantomjs-prebuilt": "^2.1.14"
}
} my quick & dirty casper: var casper = require('casper');
casper
.create()
.start('https://ezinterweb.com')
.then(function() {
this.echo('Page: ' + this.getTitle());
})
.then(function() {
this.click('#__next > div > div > div:nth-child(1) > div.menu-content > span:nth-child(3) > a');
})
.then(function() {
this.echo('Page: ' + this.getTitle());
}).run(); |
@eezing can you try it on my website? www.commandiv.com. The issue isn't getting Casper to work, it's the actual steps of filling out a form. Finding it hard to debug, but the exact casper code is above. You can just replace the |
@tgoldenberg may be it's using older version of PhantomJS. I think it might be better to use WebDriver (using real browsers) to do the testing. We are using it for Next.js itself. When I working on that, I got an issue related to this. |
May be this is related: #1120 |
@arunoda I've been looking for an issue related to my problem, and this seems to be a close hit. So I'm going to put my problem here. I'm using Jest + Enzyme to do some testing for React components. Works fine with Next.js, except for the component is trying to use I realize that the Router wasn't meant to be used on the server, but is there anyway that I could mock a fake Router or something? For instance, I've tried this approach: // My test file...
import { createRouter } from 'next/router'
createRouter({ replace: () => {} })
// .... and the tests.... And that seems to get rid of the error But anyway, the crux of the question is: what would be a good way to instantiate the Router singleton properly, so that my test cases can pass, and everything looks good to my testing suite? |
@cgood92 Thanks for the research. We are looking at a properly called |
CasperJS is a browser simulator for running end-to-end browser tests. I had a simple test suite (user visits landing page, inserts email, clicks button, get success message) that was working on my app when I was using
create-react-app
. After migrating to Next.js, the tests break mysteriously. I think it may have to do with usingRouter.push
, but I'm not sure. Has anyone used CasperJS on a Next.js-built app or has any idea why it might not be working? I appreciate any help.The text was updated successfully, but these errors were encountered: