Skip to content
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

autoLogin + run-workers = userSession.login is not a function #2620

Closed
MathieuNo opened this issue Oct 15, 2020 · 6 comments · Fixed by #2658
Closed

autoLogin + run-workers = userSession.login is not a function #2620

MathieuNo opened this issue Oct 15, 2020 · 6 comments · Fixed by #2658

Comments

@MathieuNo
Copy link

MathieuNo commented Oct 15, 2020

Hi,

I want to try to upgrade my project in Codecept 3 but I have an issue when I want to use run-workers and autoLogin plugin.
After investigation and simplify the project with the minimum test and code, I have this error :

PS D:\Dev\codecept3> npx codeceptjs run-workers 3 --verbose
CodeceptJS v3.0.0
Running tests in 3 workers...

CodeceptJS v3.0.0
CodeceptJS v3.0.0
Using test root "D:\Dev\codecept3"
Helpers: Puppeteer
Using test root "D:\Dev\codecept3"
Helpers: Puppeteer
Plugins: screenshotOnFail, autoLogin
Plugins: screenshotOnFail, autoLogin

TODOLIST --
TODOLIST --
[1] Starting recording promises
test 2
[1] Starting recording promises
test 1
CodeceptJS v3.0.0
Using test root "D:\Dev\codecept3"
Helpers: Puppeteer
Plugins: screenshotOnFail, autoLogin

TODOLIST --
[1] Starting recording promises
test 3
I am on page "http://todomvc.com/examples/angularjs/#/"
(node:8952) UnhandledPromiseRejectionWarning: TypeError: userSession.login is not a function
at loginAndSave (D:\Dev\codecept3\node_modules\codeceptjs\lib\plugin\autoLogin.js:252:21)
at loginFunction (D:\Dev\codecept3\node_modules\codeceptjs\lib\plugin\autoLogin.js:264:26)
at Context. (D:\Dev\codecept3\src\todo\todo.e2e-spec.js:6:5)
at Context. (D:\Dev\codecept3\node_modules\codeceptjs\lib\scenario.js:141:10)
at callFnAsync (D:\Dev\codecept3\node_modules\mocha\lib\runnable.js:386:21)
at Hook.Runnable.run (D:\Dev\codecept3\node_modules\mocha\lib\runnable.js:330:7)
at next (D:\Dev\codecept3\node_modules\mocha\lib\runner.js:454:10)
at cbHookRun (D:\Dev\codecept3\node_modules\mocha\lib\runner.js:495:7)
at done (D:\Dev\codecept3\node_modules\mocha\lib\runnable.js:302:5)
at D:\Dev\codecept3\node_modules\mocha\lib\runnable.js:363:11
(node:8952) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:8952) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To reproduce this, it's simple :

Install a new project with the minimum code : few scenarios in a spec file, Puppeteer helper, autoLogin plugin
Execute "npx codeceptjs run-workers 3 --verbose" command

This is my config file :

const { setHeadlessWhen } = require('@codeceptjs/configure');
setHeadlessWhen(process.env.HEADLESS);

exports.config = {
  tests: 'src/**/*.e2e-spec.js',
  output: './output',
  helpers: {
    Puppeteer: {
      url: 'http://todomvc.com/examples/vanillajs/',
      show: true,
      windowSize: '1200x900',
      waitForNavigation: ["networkidle0"], // méthode d'attente
      waitForAction: 500,
      waitForTimeout: 30000,
    }
  },
  include: {
    I: './steps_file.js',
    todo: './src/todo/todo.po.js'
  },
  mocha: {},
  name: 'codecept3',
  plugins: {
    autoLogin: {
      enabled: true,
      saveToFile: false,
      inject: 'loginAs',
      users: {
        admin: {
          login: (I) => {
            I.say('HELLO WORLD')
          },
          check: (I) => {
            I.say('HELLO WORLD 2')
          },
          fetch: (I) => {
            I.say('HELLO WORLD 3')
          },
          restore: (I, session) => {
            I.say('HELLO WORLD 4 '+session)
          },
        }
      }
    }
  }
}

I call the autoLogin function in a before step in my spec with

Before(({ I,loginAs }) => {
    loginAs('admin')
})

Details

  • CodeceptJS version: 3.0.0
  • NodeJS Version: v13.10.1
  • Operating System: Windows
  • Puppeteer Helper
@Georgegriff
Copy link
Collaborator

Have you had any luck debugging this, i also just hit this, seems to be a codeceptjs3 regression

@Georgegriff
Copy link
Collaborator

Did some debugging i think the issue lies in code that transfers config into the worker which breaks functions, it seems wrong to transfer the config like this

@Georgegriff
Copy link
Collaborator

Uploading image.png…

@Georgegriff
Copy link
Collaborator

image

Breaks thee config line, override configs is the problem
Uploading image.png…

@Georgegriff
Copy link
Collaborator

Problem lines:

this.options.override = JSON.stringify(newConfig);

Result is this line uses bad config in workers

@Georgegriff Georgegriff mentioned this issue Nov 5, 2020
31 tasks
@MathieuNo
Copy link
Author

Thank's for your reply.
I'm waiting your correction. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants