Skip to content

Releases: Ninja-Squad/ngx-speculoos

v12.0.1

27 May 13:15
Compare
Choose a tag to compare

Bug Fixes

  • missing ending parenthesis in error message (e9f07a0)

12.0.0

26 May 08:01
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • ngx-speculoos is now based on Angular 18.x. If you want to use it with an older version of Angular, then stick to a previous version of `ngx-speculoos
  • TestSelect's selectIndex, selectValue and selectLabel methods now throw if an invalid index, value or label is passed, instead of ignoring it.
  • The deprecated fakeRoute and fakeSnapshot functions have been dropped.
    Use stubRoute, or the RoutingTester instead.

Features

  • drop the deprecated fakeRoute and fakeSnapshot functions (6a5225a)
  • throw when selecting invalid index, value or label (093cb5a)
  • upgrade to Angular and CLI 18 (99af81c)

11.1.0

16 Feb 12:29
Compare
Choose a tag to compare

Features

  • introduce routing tester to test with the RouterTestingHarness (4bebe7c)

v11.0.0

15 Nov 09:45
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • ngx-speculoos is now based on Angular 17.x. If you want to use it with an older version of Angular, then stick to a previous version of ngx-speculoos.

Features

  • upgrade to Angular and CLI 17 (a838a69)

v10.0.0

05 May 08:08
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • ngx-speculoos is now based on Angular 16.x. If you want to use it with an older version of Angular, then stick to a previous version of ngx-speculoos.

Features

v9.0.0

18 Nov 08:20
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • ngx-speculoos is now based on Angular 15.x. If you want to use it with an older version of Angular, then stick to a previous version of ngx-speculoos.

Features

  • route: Allows setting the title of a route and of its snapshot (06d70d8)
  • upgrade to Angular 15 (8662e7d)

v8.0.1

17 Jun 08:44
Compare
Choose a tag to compare

Bug Fixes

  • route: make sure param maps contain the same values as params (c7859a1)

v8.0.0

03 Jun 11:40
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • ngx-speculoos is now based on Angular 14.x. It also needs RxJS v7.5+. If you want to use it with an older version of Angular, then stick to the previous version of ngx-speculoos.

v7.2.0

03 Mar 08:53
Compare
Choose a tag to compare

This release only adds the possibility to specify the routeConfig of a stub route (and its snapshot)

v7.1.0

21 Feb 20:25
Compare
Choose a tag to compare

This new release brings some exciting improvements.

stubRoute

The fakeRoute() method was clumsy: the snapshot and the reactive elements of the routes were provided separately and thus weren't necessarily consistent. Simulating a navigation was not really supported.

This function has been deprecated in favor of a new stubRoute function, which is way better. The created stub route maintains the coherence between the snapshot and the reactive parts, and simulating a navigation is as easy as calling setParams(), setQueryParams(), or other similar methods. Check the API documentation for more information.

toHaveTrimmedText matcher

A new custom matcher toHaveTrimmedText() has been added, for cases where the markup looks like

<h1>
  Some title
</h1>

and the text thus contains spaces at the beginning and at the end. toHaveText('Some title') would fail on such a case, and toContainText('Some title') wouldn't really express the tester's intention. toHaveTrimmedText('Some title') is a better choice.

Simplified jasmine mock creation

Since Angular uses classes for most services, it's possible to do some introspection to create mocks of services. That's what the createMock function does. So, instead of using

const someService = jasmine.createSpyObj<SomeService>('SomeService', ['get', 'create']);

we can simply use

const someService = createMock(SomeService);

queries by type

Until now, ngx-speculoos only allowed querying its test elements using CSS queries. To query by directive, you had to fallback to using the DebugElement. Now, all queries allow using directive types. So, assuming for example that there is an <input> element with a Datepicker directive, we can for example now use

get datepicker() {
  return this.input(Datepicker); // returns a TestInput just like the CSS query
}

queries for injection tokens

If you need to get the Datepicker directive instance itself, then use the token() method which takes a selector (CSS or type) as first argument, and the token as second argument:

get datepicker() {
  return this.token('#birth-date', Datepicker); // returns a Datepicker instance
}

queries for component instances

You can also use the component() method to get a child component instance:

get childComponent() {
  return this.component(ChildComponent); // returns the instance of ChildComponent
}

queries for custom TestElement instances

Finally, to promote the usage of custom TestElement classes (in addition to the provided TestInput, TestSelect, etc.), you can define yours and use the custom() or customs() methods to get them. For example, if you want to define a reusable TestDatepicker class, which allows querying and interacting with your custom datepicker component, you can define a custom TestElement subclass like the following:

class TestDatepicker extends TestHtmlElement<HTMLElement> {
  constructor(tester: ComponentTester<unknown>, debugElement: DebugElement) {
    super(tester, debugElement);
  }

  get inputField() {
    return this.input('input');
  }

  setDate(year: number, month: number, day: number) {
    this.inputField.fillWith(`${year}-${month}-${day}`);
  }

  toggleDropdown() {
    this.button('button').click();
  }
}

then, to get an instance of this TestDatepicker:

  get birthDate() {
    return this.custom('#birth-date', TestDatepicker);
  }