jasmine

Testacular: encountered a declaration exception

北慕城南 提交于 2019-12-23 12:25:05
问题 I have defined a empty module in angular.js: angular.module('todoList', [], function () { }) then I want test it, in my conf.js , I load these javascript: files = [ JASMINE, JASMINE_ADAPTER, // lib '../js/lib/angular.min.js', '../js/lib/jquery-1.9.1.min.js', // our app '../js/project.js', // test file "test/*.js" ]; Then I want test it in test file: describe('My own function', function(){ beforeEach(module('todoList')); }); but this step tell me FAILED My own function encountered a

Error when running tests in VueJS: Unknown custom element: <router-link>

扶醉桌前 提交于 2019-12-23 10:25:24
问题 When I run my Karma/Jasmine tests I get a Error Log in the console after mounting my header component which include <router-link> components. It all run's perfectly fine but just can't seem fix the error that displays. The error is: ERROR LOG: '[Vue warn]: Unknown custom element: <router-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in <Header>)' I have done the old: Vue.use(VueRouter) and am running "vue-router": "

Protractor: Get text of an alert?

半城伤御伤魂 提交于 2019-12-23 09:53:40
问题 I'm testing my Angular app with Protractor. I've looked through the docs and can't find any way to get the text of an alert. It's not an element in the DOM per se (at least, not that I can figure out; when there's an alert up, Chrome's inspector won't allow you to inspect it). How would I test that an alert has the correct message? Or even, that one is present? Edit Here is my code. HTML: <button id='alertButton' data-ng-click='ngAlert()'>Button</button> JS: $scope.ngAlert = function(){

Is there a way to include external Javascript as a source to Jasmine?

喜夏-厌秋 提交于 2019-12-23 09:34:05
问题 I am trying to configure jasmine.yml (using jasmine gem) to use JQuery served from Google API instead of downloading it locally to my server. I.e.: src_files: - ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js Unfortunately this does not seem to work, since (as per the comments in the config file) it is looking for filepaths relative to src_dir. Is this not possible then? Thanks Ruy 回答1: I ended up writing the javascript include via spec helper - in my case the Livereload script:

SyntaxError: Unexpected token static

给你一囗甜甜゛ 提交于 2019-12-23 09:26:40
问题 I'm currently trying to evaluate different testing frameworks that work with React, and it turns out that Jest is on my list. However, I'm trying to use static properties outlined here: https://github.com/jeffmo/es-class-fields-and-static-properties. So, I took the tutorial that is given on the Jest homepage, and added a static propTypes property, my code looks like this: import React from 'react'; class CheckboxWithLabel extends React.Component { static defaultProps = {} constructor(props) {

error TS6200: Definitions of the following identifiers conflict with those in another file (@types/jasmine)

不羁岁月 提交于 2019-12-23 09:19:23
问题 I am receiving the following error when attempting to build my project (using Angular CLI) ERROR in ../my-app/node_modules/@types/jasmine/index.d.ts(18,1): error TS6200: Definitions of the following identifiers conflict with those in another file: Expected, SpyObjMethodNames, clock, CustomEqualityTester, CustomMatcherFactory, ExpectationFailed, SpecFunction, SpyObj, jasmine I am using VSCode, and when I go to the line in question, I have the option to view the file it says its conflicting

Mocking a module imported in a vue component with Jest

放肆的年华 提交于 2019-12-23 09:16:49
问题 I'm having some issues processing the documentation of Jest, because I expected this code to work: import Vue from 'vue'; import Router from '@/router/index'; import OrdersService from '@/services/orders.service'; jest.mock('@/services/orders.service'); describe('OrdersItem.vue', () => { beforeEach(() => { // mockClear does not exist OrdersService.mockClear(); }); it('should render expected list contents', () => { // Orders.mock is undefined OrdersService.getAll.mockResolvedValue([ ... ]); //

Assert an array reduces to true

无人久伴 提交于 2019-12-23 08:56:19
问题 In one of the tests, we need to assert that one of the 3 elements is present. Currently we are doing it using the protractor.promise.all() and Array.reduce(): var title = element(by.id("title")), summary = element(by.id("summary")), description = element(by.id("description")); protractor.promise.all([ title.isPresent(), summary.isPresent(), description.isPresent() ]).then(function (arrExists) { expect(arrExists.reduce(function(a,b) { return a || b; })).toBe(true); }); Is there a better way to

isolateScope() returning undefined when testing angular directive

谁都会走 提交于 2019-12-23 08:03:15
问题 Using Angular v1.2.25 and rails asset pipeline, I am attempting to test that a directive's isolate scope has indeed been updated. Since isolateScope() returns undefined I am getting expected undefined to be defined ...' describe("cool directive", function() { beforeEach(module('necessaryModule')); var scope, $rootScope, $compile, elem, baseElement = '<div auto="mock_a" inc="mock_p" method="mock_m" reset-method="mock_r"></div>'; beforeEach(inject(function( _$rootScope_, _$compile_, _

Expect an array of float numbers to be close to another array in Jasmine

邮差的信 提交于 2019-12-23 07:27:11
问题 I'm testing a Javascript function returning an array of numbers, to see if the returned array contains the same elements as the array containing the expected output: expect(myArray).toEqual(expectedArray); This works flawlessly if myArray and expectedArray only contain integers, but fail if there is at least one float present, due to floating-point precision errors. toBeCloseTo does not seem to function on arrays. Currently I'm doing a loop to to do member-wise checking: for (var i = 0; i <