Open NinaNVY opened 8 years ago
Would you mind sharing your spec file?
Yes of course :) I'm taking Udacity "Web Tooling & Automation", they gave this spec:
describe('window height', function() {
it('returns window height', function() {
expect(getWindowHeight()).toEqual(jasmine.any(Number));
});
});
And the whole code is here: [https://github.com/udacity/ud892/tree/master/Lesson%204]
Thank you!
So, I was going through the code given and noticed that your gulp task seems to be missing the vendor: 'js/**/*.js'
found here: https://github.com/udacity/ud892/blob/master/Lesson%204/gulpfile.js#L46
That may be the source of the problem. Let me know if that helps!
Thank you for your time dear Daniel!
My code already has this vendor: 'js/**/*.js'
at line 46 :(
To detect Error I tried to run:
gulp > gulp_log.log 2> gulp_err.log
The result is here:
Maybe we could cut this problem into smaller pieces, something like this:
First, install and test jasmine alone (as node-module)
if it will work, then test jasmine with phantomjs to search for a problem with compatibility
if it will work, then search for a problem with gulp
Does it make sense?
I went ahead and cloned the courses repository down and everything works fine after npm install
for all of the missing packages (they seriously need to give you guys a package.json
file).
I think a good course of action to determine where the error might be coming from is to include this option in the task: keepRunner
. This will allow you to have a spec runner html file after it breaks. After you run the task again gulp tests
you should see a generated specRunner.html
file that you can open and then determine if the error is in your tests.
Thank you!
I added keepRunner: true;
After I ran the task again, a new spec runner html file didn't appear. I just opened the old specRunner.html, given by Udacity, and it showed no error.
I want to npm install
all of the missing packages, as you did. Would you tell me which commands to run?
@NinaNVY. I totally lead you astray. It's keepRunner: './'
not keepRunner: true
:sob:
LOL :)
Thank you! Fixed keepRunner: './'
:) and now it finally creates the new runner
html file, which shows no errors :)
But after I ran gulp tests
task, I waited 3 and a half of hours :) Here is the state of cmd all this time and the new error file
Gulp tests
task created new runner
, but after that it is simply hanging on and sleeping. So, after a few hours I pressed Ctrl+C
:)
In case if it's possible that gulp-jasmine-phantom install got messed up I decided to try running:
npm uninstall gulp-jasmine-phantom
npm install -g jasmine-core
npm install -g phantomjs
npm install gulp-jasmine-phantom
Which didn't help
Well that's infuriating. That totally sucks, sorry that it hung for so long :cry: . Could you give me your system specs (OS, Node version, NPM version, and anything else you want to add)? I will try to set up a VM and see what I can do from there.
Yes, of course, thank you!
Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz 2.40GHz
RAM 6GB
Windows10(x64)
Gulp version 3.9.0
phantomjs version 2.1.1
Node.js version 4.2.4
{ npm: '2.14.12',
ares: '1.10.1-DEV',
http_parser: '2.5.0',
icu: '56.1',
modules: '46',
node: '4.2.4',
openssl: '1.0.2e',
uv: '1.7.5',
v8: '4.5.103.35',
zlib: '1.2.8' }
And despite I installed npm install -g jasmine-core
I got this instead of jasmine version:
And I checked all possible (just my guess) permission issues here. No permission issues.
But isn't it too much work to create new VM? Maybe it would be easier to use TeamViewer?
I tried run the following command:
phantomjs /path/to/run-jasmine.js http://localhost/js/test/unit/
, here is the output:
after that it is simply hanging on and sleeping.
I ran npm install path
Here is the result:
Then I installed:
And here is the output of running phantomjs with jasmine:
Is it about process or Child Process ?
I found this:
You can start a process from within phantom via
require('child_process').spawn
That's super interesting. Have you ever been able to run phantomjs
normally without running into that issue?
For example saving this as a tiny little JS file and running it:
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://phantomjs.org/';
page.open(url, function (status) {
//Page is loaded!
phantom.exit();
});
It printed out all console.log, but didn't open any browser and the given page
Well, that's actually good. Concerning for me, but it means that your phantomjs
works! I'll spin up that VM and start working on it. I know that there are some phantomjs
issues with Windows, but that shouldn't be causing that issue.
Hi Daniel!
Thank you!
Yep, phantomjs
works alone, but it doesn't work with jasmine
together.
Would you peek at what happened after I ran npm install path
?
Here is a brand new message from phantomjs :)
Ok! So. I went ahead and forked that Lesson repository so that we help narrow down specific issues pertaining to that code base.
You can go on over here and clone that repository. Head on over to the Lesson 4
directory and do an npm install
. After that, run gulp tests
and let's see if this helped or not!
Hi Daniel! I cloned your fork with the new JSON package. Thank you! :smile: :+1:
and do an
npm install
but I have all these node modules already installed, should I install again?
Yep! There may be version differences and many other things. If you feel ok with it, I would encourage you do run npm cache clean
before npm install
just to ensure that all of the packages are installed cleanly and are up to date.
I would encourage you do run
npm cache clean
beforenpm install
I don't know what will be cleared in npm cache, if not too much trouble could you tell me in short? I know you are busy I just need some time to google it (sorry I'm a newbie).
Should I run npm uninstall
old node modules before install
new version?
Here is the definition from the npm
docs:
clean: Delete data out of the cache folder. If an argument is provided, then it specifies a subpath to delete. If no argument is provided, then the entire cache is cleared.
What that means is that when you run npm install
a cached version of that module is stored on your computer so that npm
doesn't need to make extra network requests when you make subsequent npm install
on other projects that use the same modules.
npm cache clean
will wipe that away so that you will definitively use the versions explicitly described in the package.json
Thank you for the explanation! :+1:
First I uninstall
all the old modules and second - clear the npm cache? Then install new.
I have the same problem on windows, that is , when i run the gulp task it hangs with the text "Running Jasmine with Phantom"
could it be realated to this?
Spawning .bat and .cmd files on Windows
The importance of the distinction between child_process.exec() and child_process.execFile() can vary based on platform. On Unix-type operating systems (Unix, Linux, OSX) child_process.execFile() can be more efficient because it does not spawn a shell. On Windows, however, .bat and .cmd files are not executable on their own without a terminal and therefore cannot be launched using child_process.execFile() (or even child_process.spawn()). When running on Windows, .bat and .cmd files can only be invoked using either child_process.exec() or by spawning cmd.exe and passing the .bat or .cmd file as an argument (which is what child_process.exec() does).
I tried replacing execFile with exec at at least in doesnt hang... will see if i get time to investigate further
actually, still same behaviour with ´exec´ as with ´execFile´
@henrikrudstrom please look at the end - when I tried to run phantomjs with jasmine, it asks for process variable
@dflynn15 Hi, Daniel! I need more time to follow your advice, sorry, because I have trouble now even installing Gulp. Gulp Installation tells me again and again about graceful-fs :cry: I installed the last '4.1.3' version of graceful-fs , but Gulp Installation tells me again about graceful-fs !
Here is what the npm member ashleygwilliams answered:
"probably graceful-fs is a dependency of a dependency that you are using and the semver expression that dep is using does not allow version 4. you'll have to look at the package.json of the dep that requires it. this is also why u see the lodash warning and the second graceful-fs warning. updating your other dependencies may help fix this as those lib maintainers likely (hopefully!) updated those deps."
Sorry, I'm a newbie and I need more time to understand what she wrote :(
How can I install gulp-jasmine-phantom: 3.0.0-rc1
? I can only install version 2.1.2
@NinaNVY, so first things first. Let's talk about the error when installing gulp
globally. The error there is simply saying that you do not have permission to install a global package. Usually that means the way you installed node
and npm
was through a sudo
or the directories and libraries do not give you read/write access.
A quick way around that is to sudo npm install -g gulp
but ideally you should figure out how to have read/write access to those folders. I'll link later once I find the SO answer I used a long time ago.
As for the warnings, that's just simply saying that there are dependencies that are "out of date." This is not necessarily a bad thing. Some modules depend on specific versions because the community as a whole doesn't follow semver very well. So on occasion you'll see modules explicitly depend on older versions. In this case there are dependecies that are looking for older versions of lodash
and graceful-fs
. This isn't a problem, and the warning is simply letting you know, but not erroring out :+1:
@dflynn15
Oh, Daniel, thank you for your time and kind attention! :)
so first things first. Let's talk about the error when installing gulp globally
Did I install gulp globally if I ran npm install --save-dev gulp
?
Would you tell me please how can I install gulp-jasmine-phantom: 3.0.0-rc1
? I can only install version 2.1.2
Did I install gulp globally if I ran npm install --save-dev gulp ?
So here's a quick rundown on the install flags and what each means. _This is taken from the npm install
docs here.
npm install takes 3 exclusive, optional flags which save or update the package version in your main package.json:
-S, --save
: Package will appear in your dependencies.-D, --save-dev
: Package will appear in your devDependencies.-O, --save-optional
: Package will appear in your optionalDependencies.When using any of the above options to save dependencies to your package.json, there is an additional, optional flag:
-E, --save-exact
: Saved dependencies will be configured with an exact version rather than using npm's default semver range operator.The -g or --global argument will cause npm to install the package globally rather than locally. See npm-folders.
All in all, when you did --save-dev
what it did was install a local copy of gulp
which is totally fine. However, you won't be able to use gulp
outside of the project.
As for the version 3.0.0-rc1
it will be installed if you run npm install
from the directory containing the package.json
(see here).
I think it would benefit you a lot to go through npm
s documentation and learn how it works. Specifically what a package.json
file is, how it defines packages, and what npm
tasks such as install
or start
do.
Dear Daniel! Thank you for your explanation and for your time. Very very much appreciated. Thank you! :+1: I always read documentation carefully. In the case of Udacity "Web Tooling & Automation" course they gave us just a quick 3-steps overview : 1) please install Node, Gulp, Sass, Autoprefixer, Browsersync, ESlint, Phantom, Gulp-Jasmine-Phantom, Babel, Source map etc. 2) Watch the video and try yourself how it works, to give us a taste. 3) Spend more time to read documentation for each tool carefully. On step 2 I tried every tool, except of gulp-jasmine-phantom. I saw how it works only in the instructor's video. And perhaps it make sence to move to step 3, and after completing step 3, go back to step 2 gulp-jasmine-phantom, because I'm wasting your time, sorry for the trouble. It'll take me some time to read all the documentation, and after that go back to this issue. Here is my intermediate result after reinstallation, it hangs on and sleeps :(
Same error here on Linux.
I get stuck on "Running Jasmine with PhantomJS".
I called my specRunner.html with page.render
from phantomjs
and got this screen:
Please post those specs so I can help diagnose the problem. There isn't much I can do to debug the issue with just a screenshot 😕
Nevermind, problem was on my side. Sorry I didn't read carefully docs.
I was running a custom specHtml
which didn't console messages[1].
So, phantomjs
on jasmine-runner.js
never exited.
I didn't test, but I'm sure that it will work if you put some console.log(finishRegEx)
to execute after when jasmine finishes tests, just in case...
I don't know if it's really a good idea, but at least I'd suggest please to comment about this behavior in docs.
Anyway, thank you so much for your hard work on this project!
1: because I didn't think using vendor
. Somehow, I assumed it was just for 3rd party libraries, I think that include
would be a name that would fit better to this property.
I have got the same error in my environment (Window 7, x64) I just cloned this repository (udacity), added all packages that were required by the test suite and got the error that was mentioned in that thread.
How it could be fixed?
Has anyone managed to fix this?
To replicate this error it should be enough to:
Expected behavior: gulp should be able to run the test suite and return the result
Actual result: The error is shown: [11:31:37] Finished 'tests' after 6.31 ms [11:31:37] Running Jasmine with PhantomJS
{ [Error: ENOENT: Tests contained failures. Check logs for details.] message: 'ENOENT: Tests contained failures. Check logs for details.', showStack: false, showProperties: true, plugin: 'gulp-jasmine-phantomjs', __safety: { toString: [Function: bound ] } }
I am adding my bug here because in all comments above people describe their environment. In this report I created a test repository and scenario as simple as it could be. Someone who would like to replicate this problem just need to clone a test repo install required packages and debug this problem
Environment: This bug report is related to the recent version of phanotmjs - 2.1 and the one that is installed via npm (1.9.8) Windows 7 Enterprise, x64 Nodejs: 4.4.0
Steps to reproduce:
download a test repository with as simple test as it could be: https://github.com/alexkonkin/gulp-jasmine-phantom_bug.git
install required plugins: npm install gulp npm install gulp-jasmine-phantom npm install phantomjs (or place phantomjs.exe binary to Windows/System_32 folder)
run tests by executing the command gulp tests
Expected behavior:
tests task that represents an execution of single test that engages the utilization of this plugin should be passed
Actual result:
the test is failed with the error: [10:24:26] Running Jasmine with PhantomJS
events.js:141 throw er; // Unhandled 'error' event ^ Error: ENOENT: Tests contained failures. Check logs for details.
Please also refer to the screenshot below: http://screencast.com/t/D7GGTFJ3qwC
Other info: Another plugin (https://github.com/sandermak/gulp-jasmine2-phantomjs) is also unable to run the test. Has something changed in phantomjs.exe binary?
Jasmine2 can execute this test on its own: http://screencast.com/t/Fn5kmjbypv
I cloned down the bug repo you provided and was able to run the tests running on my Mac.
Hopefully tonight I can get my Windows VM running correctly, but I would not be surprised if it had something to do with the Windows build and paths.
Thank you so much for the instant response.
As you can see from the output this test is as simple as it could be and was designed to check that the phantomjs.exe binary can be spawned by the software. Currently I don't know the reason of this problem but can suppose that somethting has been changed exactly with the windows builds of phantomjs.
I've been having a similar issue, going through the current process I think I've identified an issue, haven't had the time to check further before finishing for the day, but thought Id leave it here as a potential starting point if I don't get a chance to follow up.
It looks like the handlebars is rendered with absolute paths to assets i.e. c:\projects\my-project\src\js\some-javascript.js
which isnt a valid path for the html, I would have expected file://c:/projects....
, with the file protocol and forward slashes.
Its possible phantomjs handles this, and its a red herring on my part, but putting logging into jasmine-runner.js
it was failing to open the file with those paths in, removing the tags made it open fine
@Nysosis if you modify the jasmine-runner.js
locally to accept the file://
does the task run then? I haven't looked too deeply into why Windows version would require the file://
however the unix based systems seem to handle absolute paths in src
fine.
I tried that, but it still gave the same Tests contained failures
error
(I think because of backslashes instead of forward slashes). Where I got to
was taking that generated html, fixing it up, saving it elsewhere, and
passing it along in the specHTML
config option. That stopped the Tests contained failures
message from happening, however nothing else was
happening either (i.e. the task didn't finish), that might be due to no
tests running or something - I had to leave at the point before being able
to look any further into it
On 22 March 2016 at 16:56, Daniel Flynn notifications@github.com wrote:
@Nysosis https://github.com/Nysosis if you modify the jasmine-runner.js locally to accept the file:// does the task run then? I haven't looked too deeply into why Windows version would require the file:// however the unix based systems seem to handle absolute paths in src fine.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/dflynn15/gulp-jasmine-phantom/issues/53#issuecomment-199904873
Right, been doing some more fiddling around at home, and managed to get it running and outputting to the console as expected.
What I've had to do to get it to work:
jasmine-runner.js - line 32
- Change this to be: page.open("file:///" + system.args[1], function(status) {
'index.js - line 144` - Change this to be:
var fixupPath = function(path) {
if (path.match(/^http/)) {
return path;
}
return "file:///" + path.replace(/\\/g, '/');
}
// Create the compile version of the specRunner from Handlebars
var specData = handlebar.compile(data),
specCompiled = specData({
files: filePaths.map(fixupPath),
jasmineCss: fixupPath(jasmineCss),
jasmineJs: jasmineJs.map(fixupPath),
vendorJs: vendorJs.map(fixupPath),
specRunner: fixupPath(specRunner)
});
This works for me on a w7 box, no idea how it would affect *nix machines running the plugin.
@dflynn15 @Nysosis I did your additions to the code. It prints out to to the SpecrRunner.html this information from extraSpec.js:
describe('window height', function() {
it('returns window height', function() {
expect(getWindowHeight()).toEqual(jasmine.any(Number));
});
});
but doesn't log the same information to the cmd
Can you run this command in the folder: npm list -depth=0
, and put the output here, just so we can see what versions of packages you're using.
There's something else that I've noticed when working with that workshop repo (I presume that's the one you're using? I grabbed it from earlier messages in the issue), the runner doesn't like the space in the folder name 'Lesson 4'. If I try to run gulp tests
from there, it falls over, renaming the folder to have no space makes it work fine, and outputs to the console as expected.
@Nysosis Thank you! I renamed the folder, but same result :( And from this Lesson4 folder I installed only gulp and gulp-jasmine-phantom, because all the other packages I have installed as a node modules. Sorry if it isn't right :)
@NinaNVY My suggestion would be to check a test repo that I created and which does not contain any additional settings except one test that could allow us to detect if something is wrong with this plugin and phantomjs.exe binary otherwise we will start to debug this course from udacity and not the actual problem.
I started from the same course and then created test git repository and shared it in my bug report:
https://github.com/alexkonkin/gulp-jasmine-phantom_bug.git
repository does not contain any packages that means that you should install them before testing. Such approach would allow people to check the same thing and not the particular problems with someone's environment.
@NinaNVY I think that you can fork my repository (gulp-jasmine-phantom_bug.git), install packages and check it in your environment with the workaround that was suggested, then you can commit your changes that would allow other people to checkout it and test in their environments.
p.s.: please consider the suggestions above only as ideas that would allow us to boost the fixing process.
@alexkonkin Thank you! I did it and here is the result:
Hi, I have PhantomJS installed globally. Phantomjs binary is available in the PATH and executable from the command line. Here is my gulp task
I can not find logs and events.js:141 to see what's going wrong. Running Jasmine with minijasminenode2 goes well when I delete the string
integration: true
from my gulp task Please, help