Answer the question
In order to leave comments, you need to log in
How to properly set up Jasmine Unit testing?
Hello! I just started testing using Jasmine and ran into a situation: how to test information and books in bulk, but I didn’t fully figure out how to connect it correctly.
On the example of my test project:
src /
----/ backend
----/ frontend
Answer the question
In order to leave comments, you need to log in
First, boot.js or node_boot.js is loaded - all methods of the jasmine interface are written there in window or global. Like like this
'use strict';
var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine');
var jasmine = jasmineRequire.core(jasmineRequire);
window.jasmine = jasmine;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
var env = jasmine.getEnv();
var jasmineInterface = jasmineRequire.interface(jasmine, env);
function extend(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
extend(window, jasmineInterface);
showColors - отображать ли разноцветные сообщения, форточки не умеют
addSpecFile - добавить файлик спеки
addReporter - добавить репортер
configureDefaultReporter, он же ConsoleReporter
addMatchers не помню
loadSpecs - просто require спеков
loadHelpers - просто require хэлперов
loadConfigFile - загрузка конфига
loadConfig - загрузка конфига с объекта
addSpecFiles - добавить кучу файлов спек
onComplete - вызвать callback по завершению
stopSpecOnExpectationFailure - прервать выполнение тестов если возникает исключение
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
jasmine.loadConfig({
spec_dir: 'tests',
spec_files: [
'requests/**/*.js'
],
});
// или jasmine.loadConfigFile('spec/support/jasmine.json');
jasmine.configureDefaultReporter({
showColors: false // если это форточки
});
jasmine.execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question