dimanche 8 décembre 2019

Angular tests fails with ng e2e but pass with protractor conf.js

while working on test automation for angular apps, i faced a problem that whenever I try to run the test suit with angular command ng e2e all the tests fail. The same tests get passed with protractor command protractor conf.js. I want to ask the reason for this weird behavior. The spec is provided. Thanks

import { AddMemberClass } from '../../pages/add-member/add-member.page';
import { LoginPage } from '../../pages/login/login.page';
import { browser, promise, by } from 'protractor';


fdescribe('Add Member as Admin',()=>{

    let addMemeber: AddMemberClass;
    let login : LoginPage;

    beforeAll(()=>{
        login = new LoginPage();
        addMemeber = new AddMemberClass();
        return new Promise((resolve)=>{
            login.navigateTo().then(()=>{
                login.getEmailInput().sendKeys('something@gmail.com');
                login.getPasswordInput().sendKeys('13235');
                login.getLoginButton().click().then(()=>{
                    setTimeout(()=>{
                        expect(browser.getCurrentUrl()).toContain('organization').then(()=>{
                            resolve();
                            });
                    },30000);
                });
            });
        });    
    }); 
    
    it('should login successfully', ()=>{
        return addMemeber.getMemberMenu().click().then(()=>{
            console.log('test1');
            return addMemeber.getAddMemberSubMenu().click().then(()=>{
                 console.log('inside test 1');
                return  new Promise((resolve)=>{
                    setTimeout(()=>{
                        expect(browser.getCurrentUrl()).toContain('directregistration').then(()=>{
                        resolve();
                        });
                    },30000)
                })
            })
        })
        
    });    
   
    it('should check member Menu on main page',()=>{
        return new Promise((resolve,reject)=>{
           setTimeout(()=>{
                console.log('Inside test 2 timeout');
                expect(addMemeber.getMemberMenu().isPresent()).toBe(true);
                resolve();
            },5000)    
        });     
    });

  
    })

});

Aucun commentaire:

Enregistrer un commentaire