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

Tests don't run - 'bundle is now invalid' message #11

Closed
edoloughlin opened this issue Jun 10, 2014 · 7 comments
Closed

Tests don't run - 'bundle is now invalid' message #11

edoloughlin opened this issue Jun 10, 2014 · 7 comments

Comments

@edoloughlin
Copy link

I've got a skeleton project with dummy tests in 14 files. It all builds in under four seconds. When I run my tests, PhantomJS times out (I've tried a timeout of up to a minute). I get the following output:

DEBUG [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading karma-* from /usr/lib/node_modules
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-script-launcher.
DEBUG [plugin]: Loading plugin /usr/lib/node_modules/karma-webpack-plugin.
INFO [karma]: Karma v0.12.16 server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-71473708
DEBUG [launcher]: /usr/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-71473708/capture.js
Hash: 7b59d5bd58888f0c4037
Version: webpack 1.3.0-beta5
Time: 9ms
Asset  Size  Chunks       Chunk Names
webpack: bundle is now VALID.
webpack: bundle is now invalid.
DEBUG [web-server]: serving: /usr/lib/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /usr/lib/node_modules/karma/static/karma.js
DEBUG [web-server]: upgrade /socket.io/1/websocket/tltJALVffCGd34LjTcxd
DEBUG [karma]: A browser has connected on socket tltJALVffCGd34LjTcxd
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket tltJALVffCGd34LjTcxd with id 71473708
DEBUG [launcher]: PhantomJS (id 71473708) captured in 0.631 secs
WARN [PhantomJS 1.9.7 (Linux)]: Disconnected (1 times), because no message in 60000 ms.
DEBUG [karma]: Run complete, exitting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Process PhantomJS exited with code 0
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-71473708

I've seen that issue #8 is similar and was solved by increasing the timeout, but it doesn't work for me.

@edoloughlin
Copy link
Author

I logged more info at http://stackoverflow.com/questions/24119506/karma-jasmine-times-out-without-running-tests but there's no activity on it.

@DylanLukes
Copy link

+1

@nmccready
Copy link

My stuff was working and now I have hit this... ugh

@nmccready
Copy link

So I tweaked index.js with this.

var sha1 = function(data) {
    var hash = crypto.createHash('sha1');
    console.info("SHA1 DATA: " + data);
    hash.update(data);
    return hash.digest('hex');
};

function createPreprocesor(/* config.basePath */basePath, webpackPlugin, logger, config) {
    var log = logger.create("preprocessor.webpack");
    return function(content, file, done) {
        webpackPlugin.karmaWaitsForPreprocessing = true;


        webpackPlugin.addFile(file.path);

        // recompile
        webpackPlugin.server.invalidate()
        log.info("basePath: " + basePath);
        log.info("file.path: " + file.path);
        // read blocks until bundle is done
        webpackPlugin.readFile(path.relative(basePath, file.path), function(err, content) {
            log.info("CONTENT BLOCK: " + content);
            if(!content){
                log.error('ERROR!!! NO CONTENT to process for hash!');
                log.error('ERROR!!! err: ' + err);
                return
            }
            webpackPlugin.karmaWaitsForPreprocessing = false;
            // Hack: file.sha
            //
            // Karma v0.12 assumes preprocessing is idempotent - always returns the same result on the same input.
            // That's not true with karma-webpack. Not setting file.sha causes browser to use a cached file.
            file.sha = sha1(content);
            done(err, content && content.toString("utf-8"));
        });
    };
}

Which now gives me a better error:

╰─○ karma start
KarmaConfig: [object Object]
INFO [karma]: Karma v0.12.22 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
Hash: 606dfda4c9d20a78987a
Version: webpack 1.3.3-beta2
Time: 30ms
     Asset  Size  Chunks             Chunk Names
index.html  1129          [emitted]
webpack: bundle is now VALID.
webpack: bundle is now INVALID.
INFO [preprocessor.webpack]: basePath: /Users/nem/code/github/nmccready/rmaps/map
INFO [preprocessor.webpack]: file.path: /Users/nem/code/github/nmccready/rmaps/map/spec/app/karmaSanity.spec.coffee
INFO [preprocessor.webpack]: CONTENT BLOCK: undefined
ERROR [preprocessor.webpack]: ERROR!!! NO CONTENT to process for hash!
ERROR [preprocessor.webpack]: ERROR!!! err: Error: Path doesn't exists /_js/spec/app/karmaSanity.spec.coffee
Hash: d86dd6b2d6a1a0181b3c
Version: webpack 1.3.3-beta2
Time: 74ms
                                   Asset  Size  Chunks             Chunk Names
    _js/spec/app/karmaSanity.spec.coffee  2003       0  [emitted]  spec/app/karmaSanity.spec.coffee
_js/spec/app/karmaSanity.spec.coffee.map  2320       0  [emitted]  spec/app/karmaSanity.spec.coffee
                              index.html  1129          [emitted]
chunk    {0} _js/spec/app/karmaSanity.spec.coffee, _js/spec/app/karmaSanity.spec.coffee.map (spec/app/karmaSanity.spec.coffee) 421 [rendered]

@nmccready
Copy link

Turned out the plugin

new HtmlWebpackPlugin
  template: 'app/html/index.html'

was causing all the ruckas. I will PR my logging changes as I feel it is helpful.

@farridav
Copy link

Hi @nmccready Im having the same issue, and im also using HtmlWebpackPlugin, did you manage to find a resolution?

@nmccready
Copy link

I can't remember if I made a PR or if it got shot down. Anyways the work is here https://github.com/realtymaps/karma-webpack and https://github.com/nmccready/karma-webpack

claudiopro pushed a commit to claudiopro/karma-webpack that referenced this issue Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants