question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The check() in autologin plugin is not invoked

See original GitHub issue

What are you trying to achieve?

I am trying to assert an element by check() of auto-login plugin e.g. I.say(“Hello from check()”); << is not printed out.

What do you get instead?

The check() is not invoked: the commands inside check() has not invoked.

Provide console output if related. Use --verbose mode for more details.

Authentication --
    [1] Starting recording promises
    Emitted | suite.before ([object Object])
  log me in
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Error processing test.start event:
    TypeError: helpers[key][hook] is not a function
    at /codecept-ign/node_modules/codeceptjs/lib/listener/helpers.js:16:25
    at Array.forEach (<anonymous>)
    at runHelpersHook (/codecept-ign/node_modules/codeceptjs/lib/listener/helpers.js:15:26)
    at EventEmitter.<anonymous> (/codecept-ign/node_modules/codeceptjs/lib/listener/helpers.js:39:5)
    at EventEmitter.emit (events.js:214:15)
    at Object.emit (/codecept-ign/node_modules/codeceptjs/lib/event.js:51:28)
    at Context.test.fn (/codecept-ign/node_modules/codeceptjs/lib/scenario.js:77:13)
    at callFnAsync (/codecept-ign/node_modules/mocha/lib/runnable.js:415:21)
    at Test.Runnable.run (/codecept-ign/node_modules/mocha/lib/runnable.js:357:7)
    at Runner.runTest (/codecept-ign/node_modules/mocha/lib/runner.js:535:10)
    [1] Starting <check login> session
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I set cookie [{"name":"_gid","value":"GA1.2.716511011.1573121252","domain":".ignitionadvice.com","path":"…
    Emitted | step.after (I set cookie [{"name":"_gid","value":"GA1.2.716511011.1573121252","domain":".ignitionadvice.com","path":"/…
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I see "Admin")
    Emitted | step.after (I see "Admin")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    [1] <check login> Error | Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
    Emitted | step.failed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    [1] <check login> Error | Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
    Emitted | step.failed (I set cookie [{"name":"_gid","value":"GA1.2.716511011.1573121252","domain":".ignitionadvice.com","path":"…
    Emitted | step.finish (I set cookie [{"name":"_gid","value":"GA1.2.716511011.1573121252","domain":".ignitionadvice.com","path":"…
    [1] <check login> Error | Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
    Emitted | step.failed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    [1] <check login> Error | Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
    Emitted | step.failed (I see "Admin")
    Emitted | step.finish (I see "Admin")
 › Failed auto login for adviser due to Error: Protocol error (Page.navigate): Cannot navigate to invalid URL
 › Logging in again
    [1] <check login> Starting <auto login> session
    Emitted | step.before (I am on page "https://{{url}}/login")
    Emitted | step.after (I am on page "https://{{url}}/login")
    Emitted | step.before (I wait for visible "[data-test="login-username"]", 3)
    Emitted | step.after (I wait for visible "[data-test="login-username"]", 3)
    Emitted | step.before (I fill field "[data-test="login-username"]", "adviser.account")
    Emitted | step.after (I fill field "[data-test="login-username"]", "adviser.account")
    Emitted | step.before (I fill field "[data-test="login-password"]", *****)
    Emitted | step.after (I fill field "[data-test="login-password"]", *****)
    Emitted | step.before (I click "button[data-test="login-button"]")
    Emitted | step.after (I click "button[data-test="login-button"]")
    Emitted | step.before (I grab cookie )
    Emitted | step.after (I grab cookie )
    Emitted | step.start (I am on page "https://{{url}}/login")
    I am on page "https://{{url}}/login"
    › [Url] https://{{url}}/login
    › [Browser:Error] Failed to load resource: the server responded with a status of 400 ()
    Emitted | step.passed (I am on page "https://{{url}}/login")
    Emitted | step.finish (I am on page "https://{{url}}/login")
    Emitted | step.start (I wait for visible "[data-test="login-username"]", 3)
    I wait for visible "[data-test="login-username"]", 3
    Emitted | step.passed (I wait for visible "[data-test="login-username"]", 3)
    Emitted | step.finish (I wait for visible "[data-test="login-username"]", 3)
    Emitted | step.start (I fill field "[data-test="login-username"]", "adviser.account")
    I fill field "[data-test="login-username"]", "adviser.account"
    Emitted | step.passed (I fill field "[data-test="login-username"]", "adviser.account")
    Emitted | step.finish (I fill field "[data-test="login-username"]", "adviser.account")
    Emitted | step.start (I fill field "[data-test="login-password"]", *****)
    I fill field "[data-test="login-password"]", *****
    Emitted | step.passed (I fill field "[data-test="login-password"]", *****)
    Emitted | step.finish (I fill field "[data-test="login-password"]", *****)
    Emitted | step.start (I click "button[data-test="login-button"]")
    I click "button[data-test="login-button"]"
    Emitted | step.passed (I click "button[data-test="login-button"]")
    Emitted | step.finish (I click "button[data-test="login-button"]")
    Emitted | step.start (I grab cookie )
    I grab cookie 
    Emitted | step.passed (I grab cookie )
    Emitted | step.finish (I grab cookie )
 › Saved user session into file for adviser
    [1] <auto login> Finalize <auto login> session
    [1] Finalize <check login> session
    Emitted | test.passed ([object Object])
    Emitted | test.finish ([object Object])
  ✔ OK in 10963ms

    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

  OK  | 1 passed   // 12s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])

Provide test source code if related

//const authen = require('../pages/Login.js/index.js');
const assert = require('assert');
const {I} = inject();

Feature('Authentication');

 
 // Alternatively log in for one scenario
 Scenario('log me in', (I, loginAs) => {
    loginAs('adviser');

 });


Details

  • CodeceptJS version:
"devDependencies": {
    "@codeceptjs/mailslurp-helper": "^1.0.2",
    "codeceptjs": "^2.3.5",
    "dotenv": "^8.2.0",
    "puppeteer": "^1.20.0"
  }
  • NodeJS Version: v12.10.0
  • Operating System: MAC OS
  • Library: Pupeteer
  • Configuration file:
const env = require('dotenv').config();
//const authen = require('./specs/helper/Authentication');
let URL = env.parsed.BASED_URL;
let adviser_usr = env.parsed.ADVISER_USERNAME;
let adviser_pwd = env.parsed.ADVISER_PWD;
const mailslurp_key = require('./credential').mailslurp.key


exports.config = {
  tests: './specs/**/*.spec.js',
  output: './output',
  helpers: {
    Puppeteer: {
      //url: URL,
      show: true,
      waitForNavigation: "networkidle0"
    },
    MailSlurp: {
      require: '@codeceptjs/mailslurp-helper',
      apiKey: mailslurp_key
    },
  },
  plugins: {
    autoLogin: {
      enabled: true,
      saveToFile: true,
      inject: 'loginAs',
      users: {
        adviser: {
          loginAs: (I) => I.loginTo(`${URL}/login`, adviser_usr, adviser_pwd),
          check: (I) => {
            I.amOnPage('/');
            I.say("Hello from check()");
      
          }
        }
      }
    },
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'codecept-ign'
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
joshbax189commented, Dec 22, 2021

Same as #1591. See the answer there too: https://github.com/codeceptjs/CodeceptJS/issues/1591#issuecomment-480800333 You need to return some garbage value from fetch, e.g. just add fetch: () => "whatever" after check.

0reactions
Bakanychcommented, Sep 28, 2020

it’s still there 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

The check() in autologin plugin is not invoked #2009 - GitHub
The check() is not invoked: the commands inside check() has not invoked. Provide console output if related. Use --verbose mode for more details....
Read more >
autoLogin plugin not working like described - CodeceptJS
In documentation for autoLogin plugin it states: restore method is executed. It should open a page and set credentials. check method is ...
Read more >
Flutter shared_preferences not working in production (Google ...
I am trying to use the shared_preferences 2.0.15 Flutter package to create an autologin feature in my app. In Android, when the app...
Read more >
XIVLauncher FAQ - Custom launcher for FFXIV
How do I disable autologin? Are XIVLauncher, Dalamud, and Dalamud Plugins safe to use? How do I uninstall XIVLauncher? Will plugins/XIVLauncher work on...
Read more >
WordPress auto login after registration not working
Short answer - Your original function (mostly) works. This is your function edited to do what it needs to do:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found