Skip to main content

Questions tagged [jasmine]

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.

Filter by
Sorted by
Tagged with
1 vote
1 answer
66 views

Creating a real unit test in Karma for Angular code [closed]

This is a piece of test code made for the Angular application. The router object is a mock provided by the RouterTestingModule dependency. I wonder if such a test can be considered a unit test (...
Jelly's user avatar
  • 23
4 votes
0 answers
104 views

Formatting CSV as a table using BDD

This is the problem: Write a function to create a table from CSV data. The input to the function is a list of strings. Each string is formatted as a CSV record. Here’s an example for a ...
Boolood's user avatar
  • 41
1 vote
1 answer
978 views

Unit Test case to check if localstorage is empty once I logout of the Web app

I am trying to clear my localstorage when I am logging out of the application. I want to write a unit test case in Jasmine to check if this task is performed when logout function is run. I am writing ...
vietngogs's user avatar
  • 111
1 vote
1 answer
2k views

Unit testing static method that imports environment file

I'm (very) new to writing unit tests and I'm wondering how I should approach testing a static method that constructs our API endpoints based on what the properties are set to in our ...
Blexy's user avatar
  • 540
3 votes
1 answer
289 views

Jasmine test involving a sequence of actions

I am writing test cases in JavaScript and jQuery, the framework is Jasmine and Karma. ...
Yu Zhang's user avatar
  • 707
1 vote
2 answers
72 views

Writing unit tests for exception should be thrown case

Can anyone here comment on the quality of this test case? I am here testing for the exception should be thrown scenario. I mean it works but is it the correct way to unit test for the scenarios where ...
Vishal Anand's user avatar
4 votes
6 answers
5k views

Flatten an array of arbitrarily nested arrays of integers

Write a piece of functioning code that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]. ...
NinjaG's user avatar
  • 2,489
1 vote
1 answer
201 views

Monkey-patching Jasmine's it() function to log errors

The introduction of async native support in Jasmine doesn't log the errors (i.e., specific line number where the error occurs) to the console. So, to get around this behavior and to make the errors ...
Tums's user avatar
  • 113
4 votes
0 answers
104 views

UI testing for a web application, with variant scenarios

I'm pretty new to software testing and am currently working on a cloud-based web application. Briefly, the application uses: Ext JS as a framework Bryntum's Siesta framework for testing Currently, ...
Nuri Engin's user avatar
2 votes
2 answers
4k views

Expect all values in an array to be greater than 30

I've given an array of elements and need to check that every single text is a number greater than 30. Sample input data: ...
alecxe's user avatar
  • 17.3k
1 vote
2 answers
84 views

Unit tests for a single JavaScript function

Here is the question: What is the better way to unit test this specific function? Should all the test items be included in one test or is it better to break up the tests so each test is testing for ...
nweg's user avatar
  • 113
1 vote
1 answer
355 views

ESLint rule for Jasmine/Protractor

In Protractor, Jasmine expectations are patched to resolve WebDriver promises implicitly. For instance, if you need to assert a count of certain elements, you can use ...
alecxe's user avatar
  • 17.3k
2 votes
1 answer
15k views

Jasmine unit test that triggers mouse events in Angular 4

I have the following jasmine test spec which triggers the mouse events in my directive. As you can see there is a lot of code duplication here, I am repeating the events here. ...
ShellZero's user avatar
  • 205
4 votes
1 answer
2k views

Jasmine tests for TypeScript class's pure functions

Instead Of Intro I am a .NET developer who has recently moved to front-end realms. Unit testing was never a strong side of mine, but what I learnt is that the test code has to be of highest quality ...
Igor Soloydenko's user avatar
5 votes
1 answer
29k views

Jasmine unit tests for a function to set attributes on an HTML element

I'm new to unit testing so maybe I have this all wrong, but it seems kind of useless. I want to reduce bugs and integrate some tests with a build process however I'm not seeing the benefit at the ...
colecmc's user avatar
  • 153
2 votes
0 answers
151 views

Jasmine Unit tests for simple Angular backend interaction

I have a simple Angular application that lists some object requests from a backend, allows the users to click once to edit the item, and then click again to update the object in the backend. Here's a ...
dwjohnston's user avatar
  • 1,298
1 vote
1 answer
907 views

Angular directive test

I'm learning how to write tests in Angular (these are my first tests in general). There are a lot of tutorials out there but each one of them has a different approach. I'm a bit confused if I'm doing ...
Baki's user avatar
  • 111
1 vote
1 answer
5k views

Angular filter to format temperature

This a basic filter I created with Angular that does temperature conversion. I'd like to get thoughts on how to improve this code from both an Angular and general JS perspective. The filter should ...
cuserjuicer's user avatar
6 votes
1 answer
9k views

Jasmine unit tests for simple toggle class

Using JavaScript/jQuery I created a simple toggle and started writing unit tests for it using Jasmine. I am not sure, however, if I should be testing for things ...
spirytus's user avatar
  • 161
4 votes
1 answer
1k views

Testing async YouTube API calls using Jasmine 2.0

I'm upgrading my project from YouTube's V2 API to their V3 API. I'm also taking the time to upgrade to Jasmine 2.0 since I already need to look at my test cases. Here's a couple of test cases and the ...
Sean Anderson's user avatar
2 votes
1 answer
1k views

Integration test for database access

This integration test involves database access and hence opening and closing a database connection. Does it look correct? I am concerned about ensuring the the database connection is closed should the ...
52d6c6af's user avatar
  • 672
2 votes
1 answer
156 views

Calculate the physical centre

I'm relatively new to unit testing and having gone through quite a bit of pain I was starting to feel pretty good about my tests. The problem is, now I have a nice set of green ticks I'm also ...
John Kiernander's user avatar
5 votes
1 answer
24k views

spyOn click events and check call function

I'm trying to write Jasmine tests and I need a review and some advice on spying on events and their behavior. ...
Ronny Springer's user avatar