nightwatchjs / vite-plugin-nightwatch

Component testing plugin that integrates Vite with Nightwatch.js. Supports Vue and React components.
https://nightwatchjs.org
MIT License
15 stars 9 forks source link

launchURL should not be hardcoded to 'localhost' #22

Open tjad opened 12 months ago

tjad commented 12 months ago

The launch url is hardcoded to 'localhost'. I am wanting to do remote testing - via docker. This blocks me from being able to allow my test docker environment from using a custom url to the container hosting the vite server.

I initially logged an issue here, but I see that it is actually in the vite-plugin-nightwatch

https://github.com/nightwatchjs/nightwatch-plugin-react/issues/7

I am using a vite_dev_server setup.

https://github.com/nightwatchjs/vite-plugin-nightwatch/blob/bea1dbfb0201301cf67529a2f1c98be9a2212855/nightwatch/commands/launchComponentRenderer.js#L18

heitorsilva commented 4 weeks ago

@tjad if I'm not mistaken, you can customize what goes on this launchUrl variable via the nightwatch.conf.cjs file... for example:

test_settings: {
    default: {
      disable_error_log: false,
      launch_url: `http://127.0.0.1:${process.env.CI ? '4173' : '5173'}`,

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

      desiredCapabilities: {
        browserName: 'firefox'
      },

      webdriver: {
        start_process: true,
        server_path: ''
      }
    },

I'm using 127.0.0.1 with a ternary operator for port definition depending on the environment. Just pass what you need there and you should be fine.