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

Tests using ESModules are not recognized in Node 22 #4371

Open
yohabe opened this issue Feb 7, 2025 · 0 comments
Open

Tests using ESModules are not recognized in Node 22 #4371

yohabe opened this issue Feb 7, 2025 · 0 comments

Comments

@yohabe
Copy link

yohabe commented Feb 7, 2025

Description of the bug/issue

Tests using ESModules are not recognized in Node 22.

Steps to reproduce

  1. npm init nightwatch
  2. Select default
? Select testing type to setup for your project End-to-End testing
? Select language + test runner variant JavaScript / default
? Select target browsers Chrome
? Enter source folder where test files are stored test
? Enter the base_url of the project http://localhost
? Select where to run Nightwatch tests On localhost
? Allow Nightwatch to collect completely anonymous usage metrics? Yes
? Setup testing on Mobile devices as well? No, skip for now

...

  Nightwatch:
    version: 3.11.0
    changelog: https://github.com/nightwatchjs/nightwatch/releases/tag/v3.11.0
  1. Create a esmodule test
cat <<EOF > ./test/a.mjs
∙ export default {
    'a': function (browser) {
        browser.assert.ok(true);
    }
}
EOF
  1. [BUG] No tests is recognized with node22
$ node --version
v22.13.1

$ npx nightwatch test/a.mjs

[Test/A] Test Suite
──────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (771ms).
  Using: chrome (133.0.6943.54) on MAC.

 Wrote HTML report file to: /tmp/aa/tests_output/nightwatch-html-report/index.html

With node20, it's ok

$ node --version
v20.18.2

$ npx nightwatch test/a.mjs

[Test/A] Test Suite
──────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (750ms).
  Using: chrome (133.0.6943.54) on MAC.


  Running a:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ✔ Passed [ok]: true ok

  ✨ PASSED. 1 assertions. (3ms)
 Wrote HTML report file to: /tmp/aa/tests_output/nightwatch-html-report/index.html

Sample test

export default {
    'a': function (browser) {
        browser.assert.ok(true);
    }
}

Command to run

npx nightwatch test/a.mjs

Verbose Output


Nightwatch Configuration

// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

//  _   _  _         _      _                     _          _
// | \ | |(_)       | |    | |                   | |        | |
// |  \| | _   __ _ | |__  | |_ __      __  __ _ | |_   ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\  || || (_| || | | || |_  \ V  V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__|  \_/\_/   \__,_| \__| \___||_| |_|
//             __/ |
//            |___/

module.exports = {
  // An array of folders (excluding subfolders) where your tests are located;
  // if this is not specified, the test source must be passed as the second argument to the test runner.
  src_folders: ['test','nightwatch/examples'],

  // See https://nightwatchjs.org/guide/concepts/page-object-model.html
  page_objects_path: ['nightwatch/page-objects'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
  custom_commands_path: ['nightwatch/custom-commands'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
  custom_assertions_path: ['nightwatch/custom-assertions'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
  plugins: [],
  
  // See https://nightwatchjs.org/guide/concepts/test-globals.html
  globals_path: '',
  
  webdriver: {},

  test_workers: {
    enabled: true
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'http://localhost',

      screenshots: {
        enabled: false,
        path: 'screens',
        on_failure: true
      },

      desiredCapabilities: {
        browserName: 'chrome'
      },
      
      webdriver: {
        start_process: true,
        server_path: ''
      },
      
    },
    
    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless=new'
          ]
        }
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ]
      }
    },
    
  },
  
  usage_analytics: {
    enabled: true,
    log_path: './logs/analytics',
    client_id: 'ec4ea309-a21d-422f-b71f-0aa6801806a8'
  }
  
};

Nightwatch.js Version

3.11.0

Node Version

v22.13.1

Browser

No response

Operating System

macOS 14.7.1

Additional Information

No response

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

No branches or pull requests

1 participant