How to pass a custom error message to a jasmine matcher?

In all the testing frameworks I have used, there is an optional parameter to specify you own custom error message. This can be very useful, and I can't find a way to do this out of the box with...

Is there a jasmine matcher to compare objects on subsets of their properties

I have an object that may be extended along my behavior under test, but I want to make sure that the original properties are still there. var example = {'foo':'bar', 'bar':'baz'} var result =...

Checking object equality in Jasmine

Jasmine has built-in matchers toBe and toEqual. If I have an object like this: function Money(amount, currency){ this.amount = amount; this.currency = currency; this.sum = function...

Jasmine expect(resultCode).toBe(200 or 409)

For some test scenarios I run into the need of testing against multiple values which are all OK. What I would like to do is something as follows: expect(resultCode).toBeIn([200,409]); This spec...

where can i find a list of all built in matchers for Jasmine expect

I am trying to find a list of all existing Jasmine expect matchers like 'toContain' etc... Where can I find this? i have searched for a while but couldn't find something like an api. Jasmine site...

toBe(true) vs toBeTruthy() vs toBeTrue()

What is the difference between expect(something).toBe(true), expect(something).toBeTruthy() and expect(something).toBeTrue()? Note that toBeTrue() is a custom matcher introduced in...

Testing empty object in Jasmine fails

If I have a variable setting to {} the following match errors // Somewhere in my angular controller self = this; self.myVar = {}; // In my test file // This errors out. I console.log myVar to...

How to use regex for jasmine matchers

I need to verify the text label but it contains dynamic part, so I try to use regex but it doesn't work. expect(aboutPage.userInterfaceText.getText()).toMatch('/- User Interface: v...

Match a name to the best fitting email using regex

def email_matcher(emails_file, names_file): matches = {} with open(names_file, 'r') as names: for i in names: with open(emails_file, 'r') as emails: first =...

Create custom jasmine matcher using Typescript

I'm using jasmine on an angular2 project and having some trouble writing a custom matcher for a test. I want to be able to compare two relatively complex objects. I found this article which claims...

How to relate a version of @types to the versions of the associated package in NodeJS Typescript?

I am working on a nodejs project with typescript 2.2 that is using node 6.3.1 and I want to migrate from using typings to using @types. By doing so I ran into a set of questions related to whether...

Jasmine + Karma tests fail at a specific test count

Ran into a really odd issue yesterday while doing my Jasmine tests (which run headless usually, but can debug in Chrome). A test that usually passes seems to fail when I reach a specific total...

Intellisense not working with Jasmine on VS Code

I really enjoy to work with VS Code and intellisense is great, but I can't seem to get it to work with Jasmine and its matches. This is what im looking for:

Angular 5 Jasmine Error: Expected one matching request for criteria found none

I have a very simple service call and a jasmine test for it. Service call: myServiceCall(testId: number) : void { const url = `${this.url}/paramX/${testId}`; this.http.put(url,...

Jasmine: Matcher to be different from undefined and diferent from null (!= undefined and != null)

I had notice that if I write the expect expect(null).toBeDefined();, the test will be passed, because the jasmine considers that null is a object difined but without any value. My question is that...

angular - upgrade from material 5 to material 7 without cli

I have a complex Angular app, which is, among other things, a "hybrid" app running both Angular JS (1.6) and Angular (5.x). Right now, I need to upgrade the Material version 5.2.4 to the latest...

Use Jasmine custom matcher with Angular CLI project

I have a simple need: to use my own custom matchers in Jasmine unit tests within an Angular CLI project (Angular v6). A couple constraints: I do not want to modify anything under node_modules;...

NativeScript Unit Testing keep disconnecting

Why tns test closes blank NativeScript app? I have initialized a jasmine test from example in Unit Testing NativeScript Docs. After I run tns test android First App launches and shows correct test...

Typescript code has coverage enabled when debugging unit tests

I have a hybrid Angular App (mix between 1.7.5 and 8.2.10) which uses a mix between TypeScript and JavaScript. To run the unit tests, I have two separate npm scripts, one for the ngX tests and one...

Is it supported to pass the second argument into the toBe matcher of Jasmine?

I found this code snippet from Angular's document, but cannot find this usage from Jasmine's docs. Is this really a supported feature? I just want to make sure that if I use this feature it will...

How to let TypeScript know about custom Jest matchers?

I have a react/typescript project, using jest, where I have a custom matcher like: export const MyCustomMatchers = { toBeTheSameAsRemote: function(_util: any, _customEqualityTesters: any) { ...

Error: Expected one matching request for criteria "Match method: GET, URL: /users", found none

I have a very simple service call and a jasmine test for it. Service call: getUserInfo() { return this.http.get('/users'); } Test method: it('should get user info',...

Angular Jest Spectator - problem mocking dependency services

So I'm trying to set up my project with Jest/Spectator as it seems like a very neat way to develop tests but I'm running into issues with the dependencies for my components and services. And...

how to test authService with jasmine?

i am trying to unit test my login page using jasmine and karma but am always having this error 'Error: Expected one matching request for criteria "Match URL:...

Testing fail action - marble - ngrx Effects

I've got an issue testing a failed action on my effects. To give a bit of context here loadProducts effect is executed when the Load action is called. Inside the effect an HTTP request is...

Catch react component error in unit tests

Not able to test a react component throwing some error. Normal throw from function gets caught (Test Passes) Same throw in React does not get caught (Test Fails) // react.js function Test() { ...

Not able to use .ts files with Jasmine and Karma. Getting error 'Unable to determine file type..'

I really need some help to configure karma.conf.js to handle typescript files or not sure what is missing or what I am doing wrong here. Pretty new to unit-testing and learned the Jasmine...

query selector value is not getting in jasmine unit testing angular

I have two input fields like below <input type="number" [value]="celsius" class="large" data-test-id="celsius-input" (keyup)="getCelsius($event)"> <input type="number" [value]="fahren"...

How to fix "Cannot use import statement outside a module" when running karma unit test with angularjs?

RecordsControllerTest.spec.js // import RecordsController from '../../public/RecordsController'; import {app} from '../../public/app.js'; // without this gives "Module 'app' is not available!...

Error: node_modules/@types/jasmine/index.d.ts:668:15 - error TS2430: Interface 'FunctionMatchers<Fn>' incorrectly extends interface 'Matchers<any>'

Can anyone please tell why this issue is coming and how to resolve it. Error: node_modules/@types/jasmine/index.d.ts:668:15 - error TS2430: Interface 'FunctionMatchers' incorrectly extends...