Question

This Test code:

define([
    'intern!object',
    'intern/chai!assert',
    'require'
], function (registerSuite, assert, require) {
    registerSuite({
        name: 'index',
        'greeting form': function () {
            return this.remote
                .get(require.toUrl('index.html'))
            }
        });
})

works perfectly inside the runner (all tests pass, selenium logs show requests to be fine):

intern-runner config=tests/local.intern.js 

but when I try to use it from the standalone client, inside the browser via

http://localhost/intern-tutorial/node_modules/intern/client.html?config=tests/local.intern

two problems appear:

  • by default only unit tests are run (Why?) - they pass with flying colors;
  • explicitly requesting functional tests (via suites=tests/functional/index) returns the following error:
Error: Cannot call method 'get' of undefined
TypeError: Cannot call method 'get' of undefined
    at Test.registerSuite.greeting form [as test] (http://localhost/intern-tutorial/tests/functional/index.js:20:18)
    at Test.run (http://localhost/intern-tutorial/node_modules/intern/lib/Test.js:154:19)
    at http://localhost/intern-tutorial/node_modules/intern/lib/Suite.js:210:13
    at signalListener (http://localhost/intern-tutorial/node_modules/intern/node_modules/dojo/Deferred.js:37:21)
    at Promise.then.promise.then (http://localhost/intern-tutorial/node_modules/intern/node_modules/dojo/Deferred.js:258:5)
    at http://localhost/intern-tutorial/node_modules/intern/lib/Suite.js:209:46

I assume from the error log that no WebDriver is loaded. So, Selenium receives no requests during running this functional test. Inside the registerSuite function "this" object has this content:

    registerSuite({
        name: 'index',
        'greeting form': function () {
          // assert.strictEqual(this, {});
          console.log(JSON.stringify(this));
        },
    });

{"name":"greeting form","sessionId":null, 
"id":"main - index - #greeting form",  "timeout":30000, "timeElapsed":null,       "hasPassed":false,"error":null} this.remote is missing...
Était-ce utile?

La solution

Functional tests execute within the Node.js test runner. They cannot be run in the standalone browser client because by definition they must drive the browser from outside the browser sandbox. This is why they are defined separately from unit tests in the configuration.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top