bahmutov/cypress-watch-and-reload

No file detected, not finding watch config

Opened this issue · 2 comments

I setup a example here
https://github.com/timcash/cypress-watch-error

in the plugin it does not detect the values from cypress.json

error

Nothing to watch. Set the "cypress-watch-and-reload" object in the Cypress configuration
see https://github.com/bahmutov/cypress-watch-and-reload#use

my cypress.json

{
  "integrationFolder": "src",
  "cypress-watch-and-reload": {
    "watch": "src/*"
  }
}

plugin

/// <reference types="cypress" />

/**
 * @type {Cypress.PluginConfig}
 */
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
  // https://github.com/bahmutov/cypress-watch-and-reload
  require("cypress-watch-and-reload/plugins")(config);
  // IMPORTANT: return the config object
  // because the plugin might have changed it
  return config;
};

Had the same problem I think. Could solve it by adding the watch config directly in the plugin setup:

import watchAndReload from 'cypress-watch-and-reload/plugins';

// cypress/plugins/index.js
export default (on, config) => {
  watchAndReload({
    'cypress-watch-and-reload': {
      watch: [`src/**`],
    },
    ...config,
  });

  return config;
};
D1no commented

Same issue. Weirdly enough, console logging the config file doesn't even include the "cypress-watch-and-reload" property. So I've done the same — for me in a nx.js monorepo — works fine

module.exports = (on, config) => {
  // https://github.com/bahmutov/cypress-watch-and-reload
  require("cypress-watch-and-reload/plugins")({
    "cypress-watch-and-reload": {
      watch: [
        "../../apps/web/src/**/*.{js,ts,tsx}",
        "../../libs/**/*.{js,ts,tsx}",
      ],
    },
    ...config,
  });
  // IMPORTANT: return the config object
  // because the plugin might have changed it
  return config;
};