Skip to content

chore(test): simplify test file #2839

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

Merged
merged 1 commit into from
Nov 9, 2016

Conversation

filipesilva
Copy link
Contributor

There is no need to have System typings or asynchronously load
the testing modules.

@@ -14,21 +19,15 @@ declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};

// First, initialize the Angular testing environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please surround this by try { ... } catch(err) { karma.error(err); } to catch potential framework errors and break the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hansl I tried throwing an error in a spec file (throw new Error('error here');) with and without the catch, and it's much better without it:

# with try/catch
kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng test --no-watch
09 11 2016 00:07:29.194:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
09 11 2016 00:07:29.198:INFO [launcher]: Launching browser Chrome with unlimited concurrency
09 11 2016 00:07:29.280:INFO [launcher]: Starting browser Chrome
09 11 2016 00:07:30.590:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#guzx9l6foj0Tw_5KAAAA with id 24284547
Chrome 54.0.2840 (Windows 10 0.0.0) ERROR


Chrome 54.0.2840 (Windows 10 0.0.0) ERROR



# without try/catch
kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng test --no-watch
09 11 2016 00:06:41.269:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
09 11 2016 00:06:41.271:INFO [launcher]: Launching browser Chrome with unlimited concurrency
09 11 2016 00:06:41.279:INFO [launcher]: Starting browser Chrome
09 11 2016 00:06:42.600:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#5bLXOqjWdAOdm5VyAAAA with id 53864020
Chrome 54.0.2840 (Windows 10 0.0.0) ERROR
  Uncaught Error: error here
  at webpack:///D:/sandbox/master-proj/src/app/app.component.spec.ts:35:0 <- src/test.ts:50522

Chrome 54.0.2840 (Windows 10 0.0.0) ERROR
  Uncaught Error: error here
  at webpack:///D:/sandbox/master-proj/src/app/app.component.spec.ts:35:0 <- src/test.ts:50522

@filipesilva filipesilva force-pushed the remove-system-typing branch 3 times, most recently from 376c6c7 to 6025e99 Compare November 9, 2016 00:08
@hansl
Copy link
Contributor

hansl commented Nov 9, 2016

Okay, as long as you say that the error was not inside a test but in the file itself. LGTM.

@hansl
Copy link
Contributor

hansl commented Nov 9, 2016

I'll let you merge this.

There is no need to have System typings or asynchronously load
the testing modules.
@filipesilva filipesilva merged commit 150b3b0 into angular:master Nov 9, 2016
@filipesilva filipesilva deleted the remove-system-typing branch November 9, 2016 11:28
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
There is no need to have System typings or asynchronously load
the testing modules.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants