[phantomjs.launcher]: Fatal Windows exception, code 0xc0000005 - javascript

Firstly, this could be a duplicated issue from PhantomJS has crashed - Fatal Windows exception, code 0xc0000005. I tried the solution which was given there but it is still not working for me
I set up a webpack 4 (4.16.5) project with karma 4.0.0 (before I used karma 1.x.x but the error was still the same). It starts happening since I added more unit testing to the project (although not too much test cases).
So here's what I get when I run the test (not all the time, for example if I run it 10 times, it usually work 2-3 times)
PhantomJS 2.1.1 (Windows 8.0.0): Executed 0 of 37 SUCCESS (0 secs / 0 secs)
12 02 2019 14:01:09.798:ERROR [phantomjs.launcher]: Fatal Windows exception, code 0xc0000005.
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
12 02 2019 14:01:09.910:ERROR [launcher]: PhantomJS crashed.
Fatal Windows exception, code 0xc0000005.
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
12 02 2019 14:01:09.910:ERROR [launcher]: PhantomJS stdout:
12 02 2019 14:01:09.911:ERROR [launcher]: PhantomJS stderr: Fatal Windows exception, code 0xc0000005.
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
12 02 2019 14:01:09.915:INFO [launcher]: Trying to start PhantomJS again (1/2).
PhantomJS 2.1.1 (Windows 8.0.0) ERROR
Disconnectedreconnect failed before timeout of 2000ms (transport error)
PhantomJS 2.1.1 (Windows 8.0.0): Executed 0 of 37 DISCONNECTED (5.91 secs / 0 secs)
I follow the link http://phantomjs.org/bug-reporting.html but can't find any valuable information.
Here's the content of my karma.conf.ts
module.exports = function karmaConfig(config) {
config.set({
singleRun: true,
frameworks: [
'jasmine'
],
files: [
'sdk/**/*.spec.ts'
],
preprocessors: {
'sdk/**/*.spec.ts': ['webpack', 'sourcemap'],
'sdk/**/!(*.spec).ts': ['coverage']
},
browsers: [
'PhantomJS'
],
reporters: [
'progress',
'coverage',
'junit'
],
coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'text-summary' },
{ type: 'html' },
{
type: 'lcov',
dir: 'reports',
subdir: 'coverage'
}
]
},
junitReporter: {
outputFile: 'reports/junit/TEST-karma.xml',
useBrowserName: false
},
transports: ['polling'],
webpack: require('./webpack.config'),
webpackMiddleware: {
stats: 'errors-only'
},
logLevel: config.LOG_INFO,
});
};
Really appreciate for any suggestion on how to solve this issue, it is really annoying

Related

Karma disconnects with timeout even with 2 tests

I want to use Karma test runner with tap test framework for my project and I get stuck for parallel running of tests when there are only 2 tests
I cannot get karma to run when there is more than one test in the test folder. I have searched the issue on the net and see that most people see memory issue because of hundred tests, and mostly solve with changing timeout values. I tried changing all timeout and disconnect values but it didn't help.
I have read all those StackOverflow pages and I don't think this is a memory et all, because the same problem is seen with only 2 test. Somehow people may though its a memory problem up to this day.
And in the test, (this test runs all OK when it's only one test) only first step runs OK where I test the existence of my project -> t.ok(project, 'projectexist')
after that step, I see DISCONNECT error whatever I make timeout value. I also tried to open 2 browsers didn't help (since my test needs partners from browsers.)
browserDisconnectTimeout: 100000,
browserNoActivityTimeout: 100000,
browserDisconnectTolerance: 10,
Here is error message I get on the console
26 03 2018 09:59:37.240:WARN [Chrome 65.0.3325 (Windows 7.0.0)]: Disconnected (1 times), because no message in 10000 ms.
Chrome 65.0.3325 (Windows 7.0.0) ERROR
Disconnected, because no message in 10000 ms.
Chrome 65.0.3325 (Windows 7.0.0): Executed 0 of 0 DISCONNECTED (10.214 secs / 0 secs)
error Command failed with exit code 1.
And yet another interesting issue I see is, it fails with 2 exact same test, but if I chop one of them I see SUCCESS without running all steps in full test.
let's say I have 2 tests
1 full test
2 1 step only test
Note: Normally full test runs OK when there is only one test, also shows fail correctly if I make the code fail, but this situation above totally strange behavior when there are 2 tests in the folder
karma config file
module.exports = function (config) {
config.set({
plugins: [
require('karma-webpack'),
require('karma-tap'),
require('karma-chrome-launcher')
],
browserDisconnectTimeout: 100000,
browserNoActivityTimeout: 100000,
browserDisconnectTolerance: 10,
basePath: '',
frameworks: ['tap'],
files: ['test/**/*.js'],
preprocessors: {
'test/**/*.js': ['webpack']
},
webpack: {
node: {
fs: 'empty'
}
},
webpackMiddleware: {
noInfo: true
},
reporters: ['dots'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
})
}

Ionic 3 - Angular when import TestBed get Error : afterAll\nUncaught

I'm working on an Ionic 3 App and I have a problem when I want to use TestBed class. I use these commands to create the project.
ionic start myApp tabs
npm install karma-cli -g
npm install karma --save-dev
npm install jasmine --save-dev
npm install karma-jasmine --save-dev
npm install #types/jasmine --save-dev
npm install jasmine-core --save-dev
npm install ts-node --save-dev
npm install angular-cli --save-dev
I use karma to create this karma.conf.js :
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'src/**/*Spec.js'
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
I create the src/app/pages/home/homeSpec.js file with this content :
import { TestBed } from '#angular/core';
describe("some tests", () => {
it("True", function () {
expect(true).toEqual(true);
});
});
I get the following output when I use karma start :
------------------- without TestBed import ----------------
27 02 2018 23:45:55.793:WARN [karma]: No captured browser, open http://localhost:9876/
27 02 2018 23:45:55.807:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
27 02 2018 23:45:55.808:INFO [launcher]: Launching browser Chrome with unlimited concurrency
27 02 2018 23:45:55.812:INFO [launcher]: Starting browser Chrome
27 02 2018 23:45:57.600:INFO [Chrome 64.0.3282 (Mac OS X 10.13.3)]: Connected on socket ysC5F7d28isYt8oAAAAA with id 47800734
Chrome 64.0.3282 (Mac OS X 10.13.3): Executed 1 of 1 SUCCESS (0.002 secs / 0 secs)
------------------- with TestBed import ----------------
27 02 2018 23:46:04.564:INFO [watcher]: Changed file "/Volumes/JedemaKey/ionic_book/Chapitres/ionic/testtest/myApp/src/pages/home/homeSpec.js".
Chrome 64.0.3282 (Mac OS X 10.13.3) ERROR
{
"message": "An error was thrown in afterAll\nUncaught SyntaxError: Unexpected token {",
"str": "An error was thrown in afterAll\nUncaught SyntaxError: Unexpected token {"
}
Chrome 64.0.3282 (Mac OS X 10.13.3): Executed 0 of 0 ERROR (0.018 secs / 0 secs)
Why I get this error ?
How can I import TestBed class ?
Edit
I get same error il I can to import another class like in the following code :
import { Component } from '#angular/core';
// This line works in .ts module in same directory.
describe("Test de la page informations", () => {
it("True", function () {
expect(true).toEqual(true);
});
});
I get the same error if I give .ts extension to file...
Do you have a solution ?
Finnaly, I found solution in this Github page (https://github.com/ionic-team/ionic-unit-testing-example/issues/79). I downgrade jasmine version to 2.99.0 by using this command :
npm install --save-dev jasmine#^2.99.0

Karma Tesing on Virtual Machine

I am trying to run karma tests as part of an automated TFS build. The build opens a browser window and fails to run headless on the build server. What is the best browser configuration for this scenario?
Thanks!
the package.json script is
"headlessTest":"karma start --browsers ChromeHeadless karma.conf.js"
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '#angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('#angular/cli/plugins/karma'),
require('karma-phantomjs-launcher')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
output in console window in TFS build
[33m01 08 2017 10:03:00.043:WARN [launcher]: [39mChromeHeadless have not captured in 60000 ms, killing.
[33m01 08 2017 10:03:02.087:WARN [launcher]: [39mChromeHeadless was not killed in 2000 ms, sending SIGKILL.
[33m01 08 2017 10:03:04.208:WARN [launcher]: [39mChromeHeadless was not``killed by SIGKILL in 2000 ms, continuing.
You can try lunching the chrome with "nosandbox".
Use following configuration in your karma project.conf.js:
browsers: ['ChromeNoSandbox'],
customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: ['--no-sandbox']
}
}
Reference this Github issue: https://github.com/karma-runner/karma-chrome-launcher/issues/73#issuecomment-236597429
UPDATE:
There is an issue for Karma : github.com/karma-runner/karma/issues/2652 , whatever you can try different versions combination for Karma and Chrome, someone mentioned that downgrading to karma 1.5 worked.
You can also try to increase the Timeout value, eg 600000, then try it again.

Karamajs only running one file

I'm trying to test my client-side scripts using a gulp task in Karmajs with the browserify and mocha extensions, but only one test file is being run. Here is my gulp task
let Server = require('karma').Server;
gulp.task('client-test', function (done) {
new Server({
configFile: `${__dirname}/karma.conf.js`,
singleRun: true
}, done).start();
});
Here is my config file:
module.exports = function (config) {
config.set({
basePath: '../',
frameworks: ['mocha', 'browserify'],
files: [{ pattern: 'client/test/spec/**/*.js', included: true }],
preprocessors: {
"client/test/spec/**/*.js": ['browserify']
},
client: {
mocha: {
reporter: 'html',
ui: 'bdd'
}
},
browserify: {
debug: true,
transform: ['babelify', 'debowerify', 'brfs']
},
reporters: ['spec'],
port: 8081,
colors: true,
logLevel: config.LOG_INFO,
autowatch: true,
browsers: ['PhantomJS'],
phantomjsLauncher: {
exitOnResourceError: true
}
});
};
As you can see I'm using ** selectors to get js files in all subdirectories, but when I run the task I get the following output:
> node_modules/gulp/bin/gulp.js "client-test"
[12:24:26] Using gulpfile ~/workspace/gulpfile.js
[12:24:26] Starting 'client-test'...
[BABEL] Note: The code generator has deoptimised the styling of "/home/ubuntu/workspace/bower_components/angular-mocks/angular-mocks.js" as it exceeds the max of "100KB".
[BABEL] Note: The code generator has deoptimised the styling of "/home/ubuntu/workspace/bower_components/angular/angular.js" as it exceeds the max of "100KB".
[BABEL] Note: The code generator has deoptimised the styling of "/home/ubuntu/workspace/bower_components/rxjs/dist/rx.all.js" as it exceeds the max of "100KB".
08 06 2016 12:24:51.273:INFO [framework.browserify]: bundle built
08 06 2016 12:24:51.334:INFO [karma]: Karma v0.13.22 server started at http://0.0.0.0:8081/
08 06 2016 12:24:51.362:INFO [launcher]: Starting browser PhantomJS
08 06 2016 12:25:04.754:ERROR [phantomjs.launcher]: Fontconfig warning: ignoring C.UTF-8: not a valid language tag
08 06 2016 12:25:09.105:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#SqfLEWAUFbgjRpw6AAAA with id 21013769
AuthService
✓ Logs in a existing user
✓ Registers a new user
✓ Checks to see if a user is already authenticated
PhantomJS 2.1.1 (Linux 0.0.0): Executed 3 of 3 SUCCESS (0.152 secs / 0.041 secs)
TOTAL: 3 SUCCESS
Why is only one test file being run? What am I doing wrong?
It turns out that when there's an error in the second file, the tests won't run at all for the second file.

Grunt Karma runs tests but blocks

I have a grunt task to run Karma unit tests using Phantom JS. The tests run but the task doesn't exit. This blocks any other task from starting till I manually kill the karma:unit task using ctrl+c.
My karma.conf.js file is:
// Karma configuration
// Generated on Thu Mar 06 2014 13:17:21 GMT-0500 (Eastern Standard Time)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['mocha', 'requirejs', 'chai', 'sinon'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'src/vendor/**/*.js', included: false },
{ pattern: 'src/*.js', included: false },
{ pattern: 'src/app/*_test.js', included: false },
{ pattern: 'src/app/**/*.js', included: false },
{ pattern: 'src/app/*_test.js', included: false },
'test-main.js'
],
// list of files to exclude
exclude: [
'src/app/main.js',
'**/Gruntfile.js'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress', 'coverage'],
preprocessors: {
'src/app/**/!(*_test).js': 'coverage'
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 10000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true
});
};
My Grunt config for the karma task is:
karma: {
options: {
configFile: 'karma.conf.js'
},
unit: {
autowatch: true,
singleRun: true,
}
},
When I run grunt karma:unit, I get:
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket V2NFfUtyUi_gl0gWqbov with id 17494532
PhantomJS 1.9.7 (Windows 7): Executed 2 of 2 SUCCESS (0.012 secs / 0 secs)
but it never gets to Done, without errors until I press ctrl+C
I reinstalled karma and PhantomJS in the project and the problem cleared. I noticed that when I changed my karma configuration to use Chrome, everything worked normally so I figured the issue had to be with PhantomJS
npm install karma --save-dev
npm install phantomjs --save-dev

Categories

Resources