Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Conversation

@JiaLiPassion
Copy link
Collaborator

@JiaLiPassion JiaLiPassion commented Dec 20, 2017

fix #404.
add zone-testing-bundle.js bundle and zone-testing.js.

  1. for bazel build for Importing angular libraries and bootstrap is messy angular#21048 (comment)
  2. to resolve import order issue.
  • zone-testing-bundle.js
    in this bundle, following modules are loaded.
import '../zone';
...

import '../zone-spec/long-stack-trace';
import '../zone-spec/proxy';
import '../zone-spec/sync-test';
import '../jasmine/jasmine';
import '../zone-spec/async-test';
import '../zone-spec/fake-async-test';

@alexeagle , please review.

import 'zone.js/dist/zone-testing';

Copy link
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

This is great, it would make my example angular-bazel app a lot simpler, fixing one of these three blocks
https://github.com/alexeagle/angular-bazel-example/blob/master/BUILD.bazel

the other two I think I can fix by making angular a source dependency.

/cc @mhevery

gulpfile.js Outdated
return generateScript('./lib/testing/zone-testing.ts', 'zone-testing.js', false, cb);
});

gulp.task('build/zone-testing.min.js', ['compile-esm'], function(cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC there is no benefit to using a minified script in tests, the only possible thing someone could do is make their debugging harder. They don't care about how many bytes are loaded in Karma. what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I agree, I will remove them.

gulpfile.js Outdated
});

gulp.task('build/zone-testing-bundle.min.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/rollup-test-main.ts', 'zone-testing-bundle.min.js', true, cb);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as comment below about minified test bundle

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, you are right, we don't need minified bundle.

'build/zone.js',
'build/zone.js.d.ts',
'build/zone.min.js',
'build/zone-testing.js',
Copy link
Contributor

Choose a reason for hiding this comment

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

the scripts needed are different depending if you are testing in node or in a browser.

For node, you need to start with zone-node.js, like Misko did in this PR:
https://github.com/angular/angular/pull/21053/files#diff-8ac936419da1e3d027833281525dba0e

Maybe we should also publish zone-node-testing.js?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got it, I will make zone-node-testing-bundle

import '../zone-spec/long-stack-trace';
import '../zone-spec/proxy';
import '../zone-spec/sync-test';
import '../jasmine/jasmine';
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes an assumption about zone and jasmine being installed as siblings. Why not just import jasmine?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I am not sure I understand your suggestion, I just import ../jasmine/jasmine which include zone patch for jasmine method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, I thought this was importing jasmine library itself, but it's https://github.com/angular/zone.js/blob/master/lib/jasmine/jasmine.ts

The user does need to ensure that jasmine itself is loaded before the zone-testing bundle

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, if jasmine is not loaded, here will throw error Missing: jasmine.js

@JiaLiPassion
Copy link
Collaborator Author

@alexeagle , thank you for review, I have updated the PR. please review.


  • in this PR, there is another zone-testing.js which doesn't have direct relation with bazel build, it just make angular/cli produced src/test.ts easier and don't need to care about the import order. in zone-testing.js, zone.js itself not included.

@alexeagle
Copy link
Contributor

LGTM, I think we should probably let Misko look before merging?

/cc @hansl about improving the UX for CLI users

@JiaLiPassion
Copy link
Collaborator Author

@alexeagle , got it. thank you!

@mhevery , please review, and about zone-testing-node-bundle.js, it also include zone jasmine patch, please check it is correct or not. thank you.

@mhevery mhevery merged commit 5193838 into angular:master Dec 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.6.14 Uncaught Error: Missing: SyncTestZoneSpec for Angular RC4 tests

4 participants