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

Plugin doesn't seem to work with module aliasing #11

Open
acha5066 opened this issue Sep 28, 2023 · 0 comments
Open

Plugin doesn't seem to work with module aliasing #11

acha5066 opened this issue Sep 28, 2023 · 0 comments

Comments

@acha5066
Copy link

I'm using webpack module aliasing but it doesn't appear to be working with this plugin even though it is working when I view the built storybook.

The resolve portion of my webpack file.

  resolve: {
    extensions: [".js", ".jsx"],
    alias: {
      "opensearch-search-fetcher": path.resolve(
        __dirname,
        "src/search/fetchers/opensearch"
      ),
    },
  },

The mock in my main.js file:

  webpackFinal: async (config) => {
  config.resolve.alias = {
    ...config.resolve.alias,
    "opensearch-search-fetcher": path.resolve(__dirname, '../__mocks__/opensearch.js')
  };
  return config;
},

This works when I view storybook in the browser.

When I run the nightwatch command though it can't resolve it:

yarn run v1.22.19
warning package.json: No license field
$ npx nightwatch src/stories/Search.stories.jsx
✘ [ERROR] Could not resolve "opensearch-search-fetcher"

  src/search/components/search.jsx:11:33:
    11 │ import getOpenSearchResults from "opensearch-search-fetcher";~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path "opensearch-search-fetcher" as external to exclude it from the bundle, which will remove this error.

Wrote HTML report file to: /app/docroot/modules/custom/dnsw_react/js/tests_output/nightwatch-html-report/index.html

  Error   Error while trying to load /app/docroot/modules/custom/dnsw_react/js/src/stories/Search.stories.jsx
  Build failed with 1 error:
src/search/components/search.jsx:11:33: ERROR: Could not resolve "opensearch-search-fetcher"

error Command failed with exit code 10.

Using:

"@nightwatch/storybook": "^0.1.15",
"nightwatch": "^3.1.3",
"storybook": "^7.4.2",
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