Setting cookies for internjs functional tests

I am trying to set a cookie for a test test, but the cookie data does not seem to be available on the page. Here's the setting:

registerSuite(function() {
    'test': function() {
        return this.remote 
           .get(require.toUrl("index.html")
           .setFindTimeout(5000)
           .setCookie({name: "foo", value: "bar"})
           .then(function() {
              //... test here ...
           });
    }
});

There is no data when accessing document.cookie inside index.html. Any tips on what I'm doing wrong?

Update

I did not solve the problem, but realized that you need to call setCookie () before get (). The way I crack this is to call get () on the noop URL and then call setCookie ()

return this.remote 
       .get('/')
       .setCookie({name: "foo", value: "bar"})
       .get(require.toUrl("index.html")
       .setFindTimeout(5000)
       .setCookie({name: "foo", value: "bar"})
       .then(function() {
          //... test here ...
       });
+4
source share
1 answer

It would seem that you have not included in your example code setup, teardown/after, beforeEachor afterEach. I would recommend making sure the functionality generally works before evaluating the cookie you expect from creating it.

Intern.JS, , , , , , . , , , , , .

-1

Source: https://habr.com/ru/post/1599325/


All Articles