Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

how does expect work exactly? #128

@mren

Description

@mren

Hi.

I have some issues with expect and would love to read more documentation or the corresponding source code. But I have some problems finding the correct file for the expect function. I would be glad if someone could point me out to the file.

I started to stub the Rest Api in the protractor test.
This works fine and now I want to assert the received requests of the stubbed api.

In my example mock is a mocked middleware in a nodejs server that works like this:

mock.onRequest({path: '/foo'}).respondWith({json: {foo: 'bar'})
// access to all requests of the first mock request. In this case `/foo`
mock.routes[0].requests
// this should be empty at the moment
// later there is a list of elements like this: {body: ..., query: ....}

//ptor.get and all the selenium stuff happens here

// end of test. I want to verify if the expected parameters have been submitted
// in this case I make it simple and just check if the correct number of calls have been made
expect(mock.routes[0].requests.length).toBe(1)

In my case this always returns that no calls have been made.
The requests to the server have been made and the mock library has working unit tests for this scenarios.
As of control-flow protractor works with promises.
My guess is that protractor goes through the all the task and executes the promises if they are the first in the queue. In this case however there is no promise and protractor just uses the value. I would also assume, that protractor is using only the value and not the reference.
This could be the reason why the requests are always empty.

My question is now. How can i handle javascript objects in my protractor tests that change there values.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions