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

feat(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x #1016

Merged
merged 1 commit into from
Feb 17, 2018

Conversation

JiaLiPassion
Copy link
Collaborator

Current zone.js patch jasmine to make jasmine method run in ProxyZone, so we can do async, fakeAsync to spec.

But the patch not work for jasmine 2.9.x and jasmine 3.x version, there are two issues,

  1. the first issue is for jasmine 3.x, in the current patch, we have a global testProxyZone in jasmine, this zone s lifecycle is,
  • created when QueueRunner.prototype.execute is invoked
  • cleared (set to null) when QueueRunner.prototype.onComplete is triggered.

before jamsine 3.x, the patch work because there will only be one onComplete being triggered in execute.

but in jasmine 3.x, in QueueRunner.prototype.execute, there will be sub QueueRunner being initialized for jasmineReporter, so in one execute, there will be several QueueRunner and trigger multiple onComplete. The sequence will look like:

  • QueueRunner.execute -> testProxyZone is initialized
  • sub QueueRunner.execute (reporter.start) -> testProxyZone is initialized again
  • sub QueueRunner.onComplete -> testProxyZone is null
  • QueueRunner spec run -> testProxyZone is null throw error

so we can't use global testProxyZone any more, we need to keep the testProxyZone inside QueueRunner, and jasmine QueueRunner has a UserContext which will be initialized when new QueueRunner and will be passed to all methods such as beforeEach, it, describe and so on, so in this PR, we use UserContext to store testProxyZone per QueueRunner.

  1. the second issue is for jasmine 2.9.x, currently in test cases of zone.js we will dynamically run an it spec when ifEnvSupports return false, such kind of action is not allowed from jasmine 2.9.x because it can be only executed inside a describe. so we just print the env not support warning message.

@JiaLiPassion JiaLiPassion changed the title fix(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x WIP(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x Feb 9, 2018
@JiaLiPassion
Copy link
Collaborator Author

Some tests failed, will continue to check it, and will do test to angular repository and some test angular project which use async or fakeAsync.

@JiaLiPassion JiaLiPassion force-pushed the jasmine branch 7 times, most recently from b7b54ed to aa05c8d Compare February 15, 2018 07:21
@JiaLiPassion JiaLiPassion changed the title WIP(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x feat(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x Feb 15, 2018
@JiaLiPassion
Copy link
Collaborator Author

This PR is finished.

  • support jasmine 2.x and jasmine 3.x
  • because jasmine 3.x not support IE8 and IE9, so in travis, I will run all browsers for jasmine 2.9 and only run mainstream browsers for jasmine 3.x

@mhevery , please review, thank you.

@mhevery mhevery merged commit e1df4bc into angular:master Feb 17, 2018
@JiaLiPassion JiaLiPassion deleted the jasmine branch March 15, 2018 06:03
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.

3 participants