ngx-speculoos 13.0.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,7 @@ how to write Angular unit tests.
34
34
  - [Mocking helper](#mocking-helper)
35
35
  - [Testing with a host component](#testing-with-a-host-component)
36
36
  - [Gotchas](#gotchas)
37
- - [When do I need to call detectChanges()](#when-do-i-need-to-call-detectchanges)
37
+ - [When do I need to call detectChanges()](#when-do-i-need-to-call-change-or-detectchanges)
38
38
  - [Can I use the TestElement methods to act on the component element itself, rather than a sub-element?](#can-i-use-the-testelement-methods-to-act-on-the-component-element-itself-rather-than-a-sub-element)
39
39
  - [Issues, questions](#issues-questions)
40
40
  - [Complete example](#complete-example)
@@ -175,20 +175,21 @@ an instance of your component tester.
175
175
  ```typescript
176
176
  describe('My component', () => {
177
177
  let tester: MyComponentTester;
178
-
178
+
179
179
  beforeEach(() => {
180
180
  TestBed.configureTestingModule({
181
181
  declarations: [MyComponent],
182
182
  ...
183
183
  });
184
-
184
+
185
185
  tester = new MyComponentTester();
186
186
  tester.change();
187
187
  });
188
-
188
+
189
189
  it('should ...', () => {
190
-
190
+
191
191
  });
192
+ });
192
193
  ```
193
194
 
194
195
  ### Automatic change detection
@@ -201,11 +202,13 @@ properly handle its state changes.
201
202
 
202
203
  This can be done by:
203
204
 
204
- - adding a provider in the testing module to configure the fixtures to be in _automatic_ mode
205
+ - adding a provider in the testing module to configure the fixtures to be in _automatic_ mode,
206
+ or to use zoneless change detection
205
207
  - awaiting the component fixture stability when the test *thinks* that a change detection should
206
208
  automatically happen.
207
209
 
208
- When the `provideAutomaticChangeDetection()` provider is added, the `ComponentTester` will run in
210
+ When the `provideAutomaticChangeDetection()` or the `provideExperimentalZonelessChangeDetection()`
211
+ provider is added, the `ComponentTester` will run in
209
212
  _automatic_ mode. In this mode, calling `detectChanges()` throws an error, because you should always
210
213
  let Angular decide if change detection is necessary.
211
214
 
@@ -232,8 +235,8 @@ describe('AppComponent', () => {
232
235
  beforeEach(async () => {
233
236
  TestBed.configureTestingModule({
234
237
  providers: [
235
- provideComponentFixtureAutoDetection(),
236
- provideExperimentalZonelessChangeDetection() // if you already uses zoneless also add this provider
238
+ provideComponentFixtureAutoDetection()
239
+ // or provideExperimentalZonelessChangeDetection() if you already use zoneless
237
240
  ]
238
241
  });
239
242
 
@@ -371,7 +374,7 @@ get birthDate() {
371
374
  ```
372
375
 
373
376
  ```typescript
374
- it('should not save if birth date is in the future', () =>) {
377
+ it('should not save if birth date is in the future', () => {
375
378
  // ...
376
379
  tester.birthDate.setDate(2200, 1, 1);
377
380
  tester.save.click();
@@ -382,7 +385,7 @@ it('should not save if birth date is in the future', () =>) {
382
385
  or, in _automatic_ mode
383
386
 
384
387
  ```typescript
385
- it('should not save if birth date is in the future'), async () => {
388
+ it('should not save if birth date is in the future', async () => {
386
389
  // ...
387
390
  await tester.birthDate.setDate(2200, 1, 1);
388
391
  await tester.save.click();
@@ -1,11 +1,9 @@
1
1
  import { TestBed, ComponentFixture, ComponentFixtureAutoDetect } from '@angular/core/testing';
2
+ import { NgZone, makeEnvironmentProviders } from '@angular/core';
2
3
  import { By } from '@angular/platform-browser';
3
4
  import { RouterTestingHarness } from '@angular/router/testing';
4
5
  import { Router, ActivatedRouteSnapshot, convertToParamMap, ActivatedRoute } from '@angular/router';
5
6
  import { BehaviorSubject } from 'rxjs';
6
- import { makeEnvironmentProviders } from '@angular/core';
7
-
8
- "use strict";
9
7
 
10
8
  /**
11
9
  * A wrapped DOM element, providing additional methods and attributes helping with writing tests
@@ -538,8 +536,9 @@ class ComponentTester {
538
536
  constructor(arg) {
539
537
  this.fixture = arg instanceof ComponentFixture ? arg : TestBed.createComponent(arg);
540
538
  const autoDetect = TestBed.inject(ComponentFixtureAutoDetect, false);
539
+ const zoneless = !(TestBed.inject(NgZone) instanceof NgZone);
541
540
  this.testElement = TestElementQuerier.wrap(this.debugElement, this);
542
- this.mode = autoDetect ? 'automatic' : 'imperative';
541
+ this.mode = autoDetect || zoneless ? 'automatic' : 'imperative';
543
542
  }
544
543
  /**
545
544
  * The native DOM host element of the component
@@ -1279,7 +1278,6 @@ const speculoosMatchers = {
1279
1278
  }
1280
1279
  };
1281
1280
 
1282
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1283
1281
  function collectMethodNames(proto) {
1284
1282
  if (!proto || proto === Object.prototype) {
1285
1283
  return [];
@@ -1320,7 +1318,6 @@ function provideAutomaticChangeDetection() {
1320
1318
  return COMPONENT_FIXTURE_AUTO_DETECTION;
1321
1319
  }
1322
1320
 
1323
- /* eslint-disable */
1324
1321
  /*
1325
1322
  * Public API Surface of ngx-speculoos
1326
1323
  */