-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngapimockid cookie is set too late #54
Comments
Can you please share your code that sets the state? I'm using ng-apimock for more than 2 years now and don't have problems with it. My first guess would be a promise implementation on your side. |
@wswebcreation @mdasberg the hack below works 💪
|
I never relied on the control-flow of Protractor, so I don't know if fit('should show a placeholder when no groups exist', () => {
ngApimock.selectScenario('teacher-groups', 'empty');
page.navigateTo();
page.sleep(60000);
expect(page.chooseExistingGroups.animation).toBeDisplayed();
expect(page.chooseExistingGroups.pointers).toBeDisplayed();
}); Works. In my setup I'd always use this fit('should show a placeholder when no groups exist', async () => {
await ngApimock.selectScenario('teacher-groups', 'empty');
await page.navigateTo();
expect(await page.chooseExistingGroups.animation).toBeDisplayed();
expect(await page.chooseExistingGroups.pointers).toBeDisplayed();
}); And this never gives problems |
I thought about this, for example i tried adding async/wait for the |
👍 Can we close the issue then? |
The bug report is still valid right? If so, i would keep it open to track progress. |
The problem i'm seeing is that the ngapimockid cookie is set too late, causing the calls to the (mock) backend to lack the cookie and always returning the default mocks, eventhough i'm calling
selectScenario
. See my analysis below.When i add some
console.log
calls to myonPrepare
method inprotractor.conf
and to theng-apimock/lib/utils
ngApimockRequest
function, i see the following behavior:PUT /ngapimock/mocks/defaults c3b27ce7-503a-4069-900c-60087b52471e
This is the
setAllScenariosToDefault()
call. The uuid is the ngapimockid value.I then see the front-end doing a call:
GET /teacher/groups undefined
. Theundefined
here is the ngapimockid value.After that, i get the
console.log
i put in the "hooker" code in.tmp/ngApimock/protractor.mock.js
:When i add a
browser.sleep(60000);
in myit()
and then refresh the browser, the ngapimockid cookie is present and passed to the mock server. I then get the appropriate mock back.The text was updated successfully, but these errors were encountered: