5

I recently upgraded to protractor 2.5.1 and all of my tests are now failing. I suspect it is something to do with Jasmine but I'm not sure how to fix. Any help would be appreciated, thank you in advance. Here is the error I receive:

Should login successfully
Message:
ReferenceError: testFn is not defined
Stack:
ReferenceError: testFn is not defined
at Object. (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasminewd2\index.js:81:16)
at attemptAsync (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1809:24)
at QueueRunner.run (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1764:9)
at QueueRunner.execute (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1753:10)
at queueRunnerFactory (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:614:35)
at Object.fn (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:2338:13)
at attemptAsync (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1809:24)
at QueueRunner.run (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1764:9)
at QueueRunner.execute (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1753:10)
at queueRunnerFactory (c:\GlobalSeedField\Gsfm_Web\EndToEnd.Tests\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:614:35)

Here is my test, however the browser never even navigates to the baseUrl, it just shuts down.

import {Login} from "./Login";

describe("Login", () => {

beforeAll(() => {
    browser.get(browser.baseUrl);
});

it("Should login successfully", () => {
    Log.login(browser.params.login.username, browser.params.login.password);
    expect(browser.getLocationAbsUrl()).toBe("/");
});
});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
formarfr
  • 53
  • 4
  • What if you would reinstall `protractor` from scratch? – alecxe Dec 23 '15 at 14:44
  • Hi Alex, thanks for the response. I have tried to revert to 2.1.0, which is what I had before, but I still get the same error. – formarfr Dec 23 '15 at 15:12
  • But what if you go forward to the currently latest protractor 3.0.0? – alecxe Dec 23 '15 at 15:15
  • Unfortunately I cannot go forward to 3.0.0 as our build servers have node versions <4. 2 I ended up reverting to 2.1.0 with a fresh npm install. Once the build servers are updated I will try to skip to 3.0.0. Thanks!! – formarfr Dec 23 '15 at 16:40
  • What version of `npm` are you using? Unless you are using `npm@3` it seems odd that jasmine2wd is at `node_modules` and not `node_modules/protractor/node_modules`. I hate to say it but blowing away `node_modules` and reinstalling might help. – Nick Tomlin Dec 23 '15 at 16:48
  • Also what is `Log` in the test? Can you reproduce this without using any helpers or external modules? – Nick Tomlin Dec 23 '15 at 17:39

1 Answers1

1

This is because you are running in the "strict" mode and jasminewd2 had this problem when testFn was undefined. The fix was made in November and since Protractor depends on jasminewd2, upgrading to the latest Protractor would, surely, fix the issue.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195