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

v0.8.13 breaks unit tests with "TypeError" #837

Closed
wolfio opened this issue Jul 13, 2017 · 2 comments
Closed

v0.8.13 breaks unit tests with "TypeError" #837

wolfio opened this issue Jul 13, 2017 · 2 comments

Comments

@wolfio
Copy link

wolfio commented Jul 13, 2017

using:

  • zone.js 0.8.13
  • node 6.10.3
  • angular 4.2.5
  • rxjs 5.4.2
  • karma 1.7.0
  • typescript 2.4.1
  • jasmine 2.6.0

When using zone.js v0.8.12 unit tests work fine. With v0.8.13 I get this exception on every component test:

TypeError: Attempted to assign to readonly property. in node_modules/zone.js/dist/long-stack-trace-zone.js (line 115)
	onScheduleTask@node_modules/zone.js/dist/long-stack-trace-zone.js:115:22
	scheduleTask@node_modules/zone.js/dist/zone.js:404:65
	onScheduleTask@node_modules/zone.js/dist/zone.js:300:41
	scheduleTask@node_modules/zone.js/dist/zone.js:404:65
	scheduleTask@node_modules/zone.js/dist/zone.js:235:55
	scheduleEventTask@node_modules/zone.js/dist/zone.js:261:37
	node_modules/zone.js/dist/zone.js:1561:46
	addEventListener
	addEventListener
	listen
	listen
	listenToElementOutputs
	createViewNodes
	callViewAction
	execComponentViewsAction
	createViewNodes
	createRootView
	callWithDebugContext
	debugCreateRootView
	create
	initComponent
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/proxy.js:79:45
	invoke@node_modules/zone.js/dist/zone.js:390:40
	onInvoke
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	run
	createComponent
	createComponent
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/proxy.js:79:45
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/jasmine-patch.js:104:37
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/async-test.js:49:45
	onInvoke@node_modules/zone.js/dist/proxy.js:76:47
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/async-test.js:38:46
	invokeTask@node_modules/zone.js/dist/zone.js:424:36
	runTask@node_modules/zone.js/dist/zone.js:191:57
	invokeTask@node_modules/zone.js/dist/zone.js:499:41
	invoke@node_modules/zone.js/dist/zone.js:488:53
	timer@node_modules/zone.js/dist/zone.js:1734:34
	TypeError: Attempted to assign to readonly property. (line 59)
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/proxy.js:79:45
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/jasmine-patch.js:104:37
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/async-test.js:49:45
	onInvoke@node_modules/zone.js/dist/proxy.js:76:47
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/async-test.js:38:46
	invokeTask@node_modules/zone.js/dist/zone.js:424:36
	runTask@node_modules/zone.js/dist/zone.js:191:57
	invokeTask@node_modules/zone.js/dist/zone.js:499:41
	invoke@node_modules/zone.js/dist/zone.js:488:53
	timer@node_modules/zone.js/dist/zone.js:1734:34
	TypeError: undefined is not an object (evaluating 'element.querySelector') (line 65)
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/proxy.js:79:45
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/jasmine-patch.js:104:37
	invoke@node_modules/zone.js/dist/zone.js:391:31
	onInvoke@node_modules/zone.js/dist/async-test.js:49:45
	onInvoke@node_modules/zone.js/dist/proxy.js:76:47
	invoke@node_modules/zone.js/dist/zone.js:390:40
	run@node_modules/zone.js/dist/zone.js:141:49
	node_modules/zone.js/dist/async-test.js:38:46
	invokeTask@node_modules/zone.js/dist/zone.js:424:36
	runTask@node_modules/zone.js/dist/zone.js:191:57
	invokeTask@node_modules/zone.js/dist/zone.js:499:41
	invoke@node_modules/zone.js/dist/zone.js:488:53
	timer@node_modules/zone.js/dist/zone.js:1734:34

It seems this happens because the beforeEach within the component tests is not finished. It looks like it fails after calling TestBed.createComponent(MyComponent)

beforeEach(() => {
      fixture = TestBed.createComponent(MyComponent);
      component = fixture.componentInstance;
      element = fixture.debugElement.nativeElement;

      fixture.detectChanges();
    });

because code afterwards is not executed and therefore some objects are undefined.

@JiaLiPassion
Copy link
Collaborator

duplicate with #832, it have been fixed in #834.

@JiaLiPassion
Copy link
Collaborator

Close for now for fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants