e2e-testing

In Cypress, set a token in localStorage before test

寵の児 提交于 2019-12-02 22:08:57
I want to login and set a localStorage token on the client (specifically jwt ) How can I accomplish this using cy.request , as suggested in the Cypress Documentation? Here's an example of adding a command cy.login() that you can use in any Cypress test, or put in a beforeEach hook. Cypress.Commands.add('login', () => { cy.request({ method: 'POST', url: 'http://localhost:3000/api/users/login', body: { user: { email: 'jake@jake.jake', password: 'jakejake', } } }) .then((resp) => { window.localStorage.setItem('jwt', resp.body.user.token) }) }) Then in your test: beforeEach(() => { cy.login() }) I

angular e2e testing : how to test Service inject(use) another services

一曲冷凌霜 提交于 2019-12-02 15:35:50
问题 i'm trying to test my service with e2e test angular 7, my problem is i don't know how to do that: it's my service, (the methode return Observable): import { Injectable } from '@angular/core'; import { UrlDecoratorService } from "../../common/url-decorator.service"; import { APIFetcherService } from "../common/api-fetcher.service"; import { Observable } from 'rxjs'; import { IALChrono, ALChrono } from '../../common/IALChrono.interface'; @Injectable() export class AnnonceChronoDetailService {

angular e2e testing : how to test Service inject(use) another services

好久不见. 提交于 2019-12-02 08:33:38
i'm trying to test my service with e2e test angular 7, my problem is i don't know how to do that: it's my service, (the methode return Observable): import { Injectable } from '@angular/core'; import { UrlDecoratorService } from "../../common/url-decorator.service"; import { APIFetcherService } from "../common/api-fetcher.service"; import { Observable } from 'rxjs'; import { IALChrono, ALChrono } from '../../common/IALChrono.interface'; @Injectable() export class AnnonceChronoDetailService { private months: string[]; constructor(private urlDecoratorService: UrlDecoratorService, private

Protractor unable to find elements and script timeout

徘徊边缘 提交于 2019-12-02 04:28:42
问题 I'm running protractor, it runs successfully and load my angular app. The very first test I wrote is to get the sign-up button. Although I can see the sign-up button in my view and I'm targeting it with proper CSS. Still, all I get is this error after running the test. App ✗ should get the text of sign up button - Failed: script timeout: result was not received in 11 seconds (Session info: chrome=71.0.3578.98) (Driver info: chromedriver=2.45.615355 (d5698f682d8b2742017df6c81e0bd8e6a3063189)

Select OK button from N'th modal opened in testcafe

邮差的信 提交于 2019-12-01 21:28:57
I open two modals in my testing, and I want to be able to click on the "OK" button in the second modal (the second selected element in the below html). My current code is : import { waitForReact } from 'testcafe-react-selectors'; import { Selector } from 'testcafe'; fixture `App tests` .page('http://localhost:3000/') .beforeEach(async () => { await waitForReact(); }); test('Can open and accept all pop ups', async t => { //open first modal await t .click('#LayerAddingPopUpButtonID'); //select OK button from first modal const modalOKButton = Selector('div.ant-modal') .find('div.ant-modal-footer'

Testcafe - Test command line argument outside test case

£可爱£侵袭症+ 提交于 2019-12-01 17:47:56
As I'm getting familiar with Testcafe, I'm trying to use a command line argument to give the user more information on how to run tests. For that reason, I'm using the minimist package. However, I cannot print or use any variables outside the test cases. Please find below my code. import { Selector } from 'testcafe'; import minimist from 'minimist'; const args = minimist(process.argv.slice(2)); const env = args.env; console.log('*** A SAMPLE CONSOLE OUTPUT ***'); // does not print fixture `Getting Started` .page `http://devexpress.github.io/testcafe/example`; test('My first test', async t => {

Testcafe - Test command line argument outside test case

强颜欢笑 提交于 2019-12-01 17:44:54
问题 As I'm getting familiar with Testcafe, I'm trying to use a command line argument to give the user more information on how to run tests. For that reason, I'm using the minimist package. However, I cannot print or use any variables outside the test cases. Please find below my code. import { Selector } from 'testcafe'; import minimist from 'minimist'; const args = minimist(process.argv.slice(2)); const env = args.env; console.log('*** A SAMPLE CONSOLE OUTPUT ***'); // does not print fixture

Selecting angular-ui date-picker value from the calendar using Protractor

一个人想着一个人 提交于 2019-12-01 13:27:44
My datepicker structure looks like: <button type="button" class="date-picker-item"> <span>1</span> </button> <button type="button" class="date-picker-item"> <span>2</span> </button> etc.. I am trying to use by.cssContainingText from the protractor api. element.all(by.cssContainingText('.date-picker-item > span', day)) but its not selecting it at the minute. Do I need to target this a different way? Thanks a lot in advance. In one of my project i wrote function like this: elementDate: function(inArray,object){ var day = inArray.day.toString(); var cYear = new Date(); var cYear = cYear

“angular is not defined” error while executing Protractor test on angular application stored in Liferay

核能气质少年 提交于 2019-12-01 04:27:43
i'm running on a Ubuntu 14.04 virtual-host and i'm trying to create some E2E tests with PROTRACTOR for and Application hosted in "Liferay". For the login section (that doesn't require angular) the test with protractor are Ok, the page logins and navigates correctly, but when i try to open a "drop-down" menu on the angularjs based app with the following code: <select class = "form-control menu-select ng-pristine ng-valid" ng-model = "topTitlesData.topFiveDateRange" name = "topFiveDateRange" ng-options = "range.name for range in topTitlesData.topFiveDateRangeValues" ng-change = "" > < option

“ReferenceError: System is not defined” when using protractor with Angular2 and .ts specs

旧城冷巷雨未停 提交于 2019-11-30 20:32:30
I want to do e2e testing on a hello world app in Angular2 with specs written in typescript. However, protractor crashes with the following message: Using the selenium server at http://localhost:4444/wd/hub [launcher] Running 1 instances of WebDriver [launcher] Error: ReferenceError: System is not defined at Object.<anonymous> (C:\Dev\d2ipm\test\e2e\overview.js:1:1) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module