我们正在尝试使用Protractor测试其上有“导航执行”的React组件。我们的想法是强制执行顺序流程 - 禁止用户使用网址栏进行导航,而不是通过应用程序自然地进行导航。
功能正常,这些测试在一些机器上传递,但在其他机器上给出了“Jasmine spec has timed out”错误。如果我们注释掉另一个,这些测试都没有通过,所以我们无法进一步缩小范围。
我们不知道这两个测试有什么问题吗?
describe('Given navigation enforcer-wrapped component selectVehicle', () => {
let until = protractor.ExpectedConditions
beforeAll(() => {
browser.ignoreSynchronization = true
})
describe('When a user attempts to navigate to a previous component', () => {
beforeAll(() => {
browser.get('/#/verifyInformation')
browser.wait(until.presenceOf(element(by.id('verify-information-container'))), 3000, 'Verify Information not loading')
})
it('Then they successfully navigate to the requested route', () => {
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '/#/verifyInformation')
})
afterAll(() => {
browser.get('/#/vehicleSelection')
})
})
describe('When a user attempts to navigate to a step BEYOND where they have progressed in the app', () => {
beforeAll(() => {
browser.get('/#/damages')
browser.wait(until.presenceOf(element(by.id('select-vehicle-container'))), 3000, 'vehicleSelection not loading')
})
it('Then they NOT brought to their requested route and are instead redirected to their current page', () => {
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '/#/vehicleSelection')
})
})
})