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
 Nguyen Phong Thien
 Nguyen Phong ThienUser contributions licensed under CC BY-SA 3.0