ninja-squad / ngx-speculoos Goto Github PK
View Code? Open in Web Editor NEWSimpler, cleaner Angular unit tests
Home Page: https://ngx-speculoos.ninja-squad.com/
License: MIT License
Simpler, cleaner Angular unit tests
Home Page: https://ngx-speculoos.ninja-squad.com/
License: MIT License
Hi,
First of all (and like the last time I saw you), thanks for the job done inside the pro pack and for this libs (and valdemort too).
I'm currently writing slides for VoxxedDays Luxembourg and I think this lib is a must have for me in my presentation. But I'm currently trying to replace the default test written by the CLI with some using the ComponentTester
But, I think a complete example project is something missing in this repository.
Examples in compodoc are a bit too short and some ...
hide things not trivial for everyone.
In my case, I had to use the method detectChanges()
. Without this call, the component template doesn't have its text bindings initialised.
So, without this detectChanges()
, I have this error:
Expected element to contain text 'Welcome to app!', but had text ' Welcome to '
at UserContext.<anonymous> src/app/app.component.spec.ts:39:26)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:388:1)
at AsyncTestZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.AsyncTestZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:713:1)
at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:285:1)
For a very simple component :
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
With template :
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<img width="300" alt="Angular Logo" src="...">
</div>
So, I would like to know if this is a correct way to use the ComponentTester<T>
in this kind of test ?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.circleci/config.yml
browser-tools 1.4.8
cimg/node 18.19-browsers
package.json
@angular/common 17.3.0
@angular/compiler 17.3.0
@angular/core 17.3.0
@angular/forms 17.3.0
@angular/platform-browser 17.3.0
@angular/platform-browser-dynamic 17.3.0
@angular/router 17.3.0
rxjs 7.8.1
tslib 2.6.2
zone.js 0.14.4
@angular-devkit/build-angular 17.3.0
@angular-eslint/builder 17.3.0
@angular-eslint/eslint-plugin 17.3.0
@angular-eslint/eslint-plugin-template 17.3.0
@angular-eslint/schematics 17.3.0
@angular-eslint/template-parser 17.3.0
@angular/cli 17.3.0
@angular/compiler-cli 17.3.0
@compodoc/compodoc 1.1.23
@types/jasmine 5.1.4
@typescript-eslint/eslint-plugin 7.3.0
@typescript-eslint/parser 7.3.0
codecov 3.8.3
eslint 8.57.0
eslint-config-prettier 9.1.0
eslint-plugin-ban 1.6.0
eslint-plugin-deprecation 2.0.0
eslint-plugin-prettier 5.1.3
jasmine-core 5.1.2
karma 6.4.3
karma-chrome-launcher 3.2.0
karma-coverage 2.2.1
karma-jasmine 5.1.0
karma-jasmine-html-reporter 2.1.0
ng-packagr 17.3.0
prettier 3.2.5
standard-version 9.5.0
typescript 5.2.2
projects/ngx-speculoos/package.json
tslib 2.6.2
@angular/core ^17.0.0
@angular/platform-browser ^17.0.0
@angular/router ^17.0.0
rxjs ^7.8.0
Seen in https://github.com/Ninja-Squad/ngx-speculoos/blob/master/README.md#ngx-speculoos
It also provides utilities to make writing Angular unit tests.
There is probably a missing word.
"utilities to make writing Angular unit tests easier", maybe?
It exists for buttons, but not for those TestXxx classes
Hi,
Like previously exposed (on twitter), I'm working with Jest on Angular. Are you interested in migrating the current matchers for the Jest world?
I will do a PR if you're ok.
Thanks
In the documentation, code blocks seems to not be displayed correcly (see screenshot below).
It seems to come from a regression in compodoc 1.1.9 :
compodoc/compodoc#765
We should add a basic example on home page, like the one we have in the readme.
Currently when you land on https://ngx-speculoos.ninja-squad.com/ you don't really know what it's about, whereas we have examples on https://ngx-valdemort.ninja-squad.com/#/
When reading the doc (https://ngx-speculoos.ninja-squad.com/documentation/index.html), the last chapter mention filling issues or PRs, but there are no links to repository.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
My test case: I have a radiobutton group, with two options:
"allStatus" or "inProgressStatus"
The following test will fail
it('should update criteria model when changing criteria', () => {
// Given
loadTester();
// When
tester.inProgressStatus.check();
tester.allStatus.uncheck();
// Then
expect(tester.componentInstance.form.getRawValue()).toEqual({
inProgress: 'true'
});
});
while the following (just inverting uncheck/check) will pass
it('should update criteria model when changing criteria', () => {
// Given
loadTester();
// When
tester.allStatus.uncheck();
tester.inProgressStatus.check();
// Then
expect(tester.componentInstance.form.getRawValue()).toEqual({
inProgress: 'true'
});
});
(thanks for this great library by the way)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.