Questions tagged [jasmine]

Jasmine is a behavior-driven development (BDD) framework for testing JavaScript code. Jasmine has no external dependencies and does not require a DOM.

Jasmine is a stand-alone behavior-driven development (BDD) framework used for unit testing JavaScript code.

Jasmine tests are broken up into describe and it statements. describe is used to denote the start of a test suite and it is used to denote the start of a particular test. expect statements are then used to outline the conditions under which a test should pass.

beforeEach and afterEach are some other frequently used blocks. beforeEach is used to run some code before each test. Something like loading a module. Similarly afterEach is used to run some code after each test. Running some cleanup code for instance.

Jasmine DOM Testing

If you want to write unit tests for code that does a lot of DOM interactions using jQuery, consider using jasmine-jquery. Jasmine-jQuery offers interacting with dummy HTML through HTML fixtures.

Resources

12446 questions
4
votes
0 answers

some errors about jasmine clock in Angular unit test

Here are codes: // component export class MockDateComponent implements OnInit { date: number; // ... initDate() { this.date = new Date().getTime() } } // spec describe('...', () => { // ... it('should init date…
ishowman
  • 61
  • 5
4
votes
0 answers

Random Jasmine-related errors after computer dies

So I was writing in some comments in a new component I was writing, and then to my dismay, my laptop ran out of battery and turned off. I had my server running whilst this happened. Normally this would be no big deal, I'll just turn it back on and…
Matt Strom
  • 516
  • 3
  • 19
4
votes
1 answer

TypeError: Method Promise.prototype.then called on incompatible receiver Proxy

to perform integration testing I used jasmine and puppeteer and since I am passing an educational course ,according to that ,I decided to use a js Proxy to encapsulate testing functionality but when I do my test I will encounter with the following…
4
votes
1 answer

Error debugging protractor with node 8 async/await and angular 6

I can not get the protractor debugger to work with node 8 async/await and Angular 6. Going back to node 7 in the old way with elementExplorer, browser.pause() and browser.debugger() is not an option. Also because in the future, the control flow is…
Herman Fransen
  • 1,938
  • 4
  • 21
  • 38
4
votes
1 answer

ERROR in error TS2688: Cannot find type definition file for 'jest'

I have an angular 6 application and I'm using karma + jasmine to run my tests. but when I run ng test I'm getting the following error: ERROR in error TS2688: Cannot find type definition file for 'jest'. Any one knows how to solve this problem?
Ricardo Rocha
  • 8,628
  • 9
  • 53
  • 91
4
votes
1 answer

Using [(ngModel)] does not apply change in unit test for inputs inside ngFor

I'm having trouble testing an Angular component that utilizes the two way [(ngModel)] binding on checkbox inputs inside an ngFor. It works just fine in the actual app. This is just a problem with the test. Here's an example test that fails: import {…
Rich McCluskey
  • 1,571
  • 1
  • 13
  • 24
4
votes
1 answer

angular 7 unit test throws env.configure is not a function\nat and hangs

I am getting this error: "message": "Uncaught TypeError: env.configure is not a function\nat /Users/darrylwagoner/dev/statellite-web-client/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js:74:7\n\nTypeError: env.configure is not a…
4
votes
0 answers

Karma + Jasmin ordered test running

Fail to run tests in strict order. package.json { "version": "0.0.1", "description": "", "main": "./src/main.ts", "scripts": { }, "devDependencies": { "@types/jasmine": "^2.8.9", "concurrently": "^4.0.1", "jasmine":…
4
votes
1 answer

How to properly unit test throwing error for API services with Jasmine in Angular?

I'm pretty new to Angular and Jasmine framework. I've written some api services wrapping HttpClient to make get/post calls and now I want to unit test the get method to ensure it properly catches and throws the right error. My api.service.ts looks…
Charles.S
  • 41
  • 1
  • 3
4
votes
1 answer

How to wait for request to be finished with axios-mock-adapter like it's possible with moxios?

I try to test a rendering of some content after fetching it from server. I use Vue Test Utils but this is irrelevant. In the created hook of the component the ajax call is made with axios. I register the axios-mock-adapter response and 'render' the…
Paul Geisler
  • 695
  • 1
  • 5
  • 23
4
votes
1 answer

How to unit test statement 'chart.chart.update()' in jasmine?

I have a Angular 4 app and I am using angular2-chartjs to plot charts in my application. In the component, I have imported following: import { ChartComponent } from 'angular2-chartjs'; import { ChartModule } from 'angular2-chartjs'; Created a chart…
DR39
  • 363
  • 1
  • 16
4
votes
1 answer

Async beforeEach finished before/after each test unit(it)

Hey I am new to tests in angular 6(aka angular) and I have one concern regrading every test which I have seen so far. Let's first look at a simple test of simple component(which is generated by cli) describe('CompComponent', () => { let component:…
Brk
  • 1,155
  • 18
  • 46
4
votes
0 answers

Unit testing for dropdown selection angular 5

I am trying to test drop down selection, I am able to get nativeElement and options, but I am facing error with dispatch event some how event is not captured. HTML