Skip to content

Error with npm run test (karma start) #901

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

Closed
lgarro opened this issue Aug 25, 2016 · 5 comments
Closed

Error with npm run test (karma start) #901

lgarro opened this issue Aug 25, 2016 · 5 comments

Comments

@lgarro
Copy link

lgarro commented Aug 25, 2016

Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @AngularClass

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
  • Do you want to request a feature or report a bug?

I want to report a bug with karma test on the latest RC5

  • What is the current behavior?

When you run npm test in the console, you get the following error

ERROR in ./karma-shim.js
Module not found: Error: Cannot resolve module 'zone.js/dist/proxy-zone' in /Users/lgarro/Documents/starter/angular2-webpack-master
@ ./karma-shim.js 12:0-34
webpack: bundle is now VALID.
25 08 2016 14:10:38.469:INFO [karma]: Karma v1.1.2 server started at http://localhost:9876/
25 08 2016 14:10:38.471:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
25 08 2016 14:10:38.478:INFO [launcher]: Starting browser PhantomJS
25 08 2016 14:10:39.035:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#putuvgbU1fkhCjOdAAAA with id 85751166
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
Error: Cannot find module "zone.js/dist/proxy-zone"
at undefined:12
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
Error: Cannot find module "zone.js/dist/proxy-zone"
at undefined:12

Finished in 0.144 secs / 0 secs

Steps to reproduce:

1- Open up starter in the ide of your choice
2- Run npm install to install dependencies
3-Run "npm run test"

  • What is the expected behavior?

Basic tests included in the starter should pass, and no error should be shown in the console

  • What is the motivation / use case for changing the behavior?

Run tests

  • Please tell us about your environment:

OS: OSX El capitan
Browser: chrome

"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
}]

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
@StefH
Copy link
Contributor

StefH commented Aug 26, 2016

See also angular/zone.js#404

@egervari
Copy link

I also get this error, in the karm-test-shim.js

@egervari
Copy link

I changed a few things with the starter, and this appears to work. I make the karma-test-shim into a typescript file.

import 'core-js/es6';
import 'core-js/es7/reflect';
import 'reflect-metadata';

import 'zone.js/dist/zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';

Error.stackTraceLimit = Infinity;

var appContext = (<{ context?: Function }>require).context('../src', true, /\.spec\.ts/);

appContext.keys().forEach(appContext);

var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');

testing.TestBed.initTestEnvironment(
    browser.BrowserDynamicTestingModule,
    browser.platformBrowserDynamicTesting()
);

Then I changed the following in the karma.conf.js:

        files: [
            {pattern: './config/karma-test-shim.ts', watched: false}
        ],

        preprocessors: {
            './config/karma-test-shim.ts': ['webpack', 'sourcemap'],
            './src/**/!(*.spec).(ts|js)': [
                'sourcemap'
            ]
        },

@PatrickJS
Copy link
Owner

@egervari can you make a pull-request?

@uweDuesing
Copy link

@egervari
Thanks a lot for your patch, works fine for me!

awcodify pushed a commit to awcodify/d3-angular-4 that referenced this issue Aug 28, 2017
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