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.
23 questions
1
vote
1
answer
84
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 (...
4
votes
0
answers
121
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 ...
1
vote
1
answer
1k
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 ...
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 ...
3
votes
1
answer
303
views
Jasmine test involving a sequence of actions
I am writing test cases in JavaScript and jQuery, the framework is Jasmine and Karma.
...
1
vote
2
answers
102
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 ...
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].
...
1
vote
1
answer
237
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 ...
4
votes
0
answers
114
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, I'...
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:
...
1
vote
2
answers
106
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 ...
1
vote
1
answer
375
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 ...
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.
...
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 ...
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 ...