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

Syntax error when passing the runOnly option #10

Open
acha5066 opened this issue Sep 21, 2023 · 1 comment
Open

Syntax error when passing the runOnly option #10

acha5066 opened this issue Sep 21, 2023 · 1 comment

Comments

@acha5066
Copy link

acha5066 commented Sep 21, 2023

When using the default config the tests run correctly:

  parameters: {
    // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
    layout: "centered",
    a11y: {},
  },
[Search.stories.jsx component] Test Suite
───────────────────────────────────────────────────────────────────────────────
ℹ Connected to selenium_chrome on port 4444 (242ms).
  Using: chrome (94.0.4606.61) on LINUX.


  Running "Default" story:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ✖ NightwatchAssertError
   There are accessibility violations; please see the complete report for details.

    Read More : 
    https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md 

  FAILED: 1 assertions failed (1.04s)

I want to specify tags to run using the runOnly options like below:

parameters: {
    // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
    layout: "centered",
    a11y: {
      options: {
        runOnly: {
          type: "tag",
          values: ["wcag2a", "wcag2aa"],
        },
      },
    },
  },

Which results in a syntax error?

[@nightwatch/storybook] Found 1 total number of story files, of which 1 were ignored due to errors.
[@nightwatch/storybook] Found 1 total number of story files, of which 1 were ignored due to errors.
[@nightwatch/storybook] Found 1 total number of story files, of which 1 were ignored due to errors.
Wrote HTML report file to: /app/docroot/modules/custom/foobar_react/js/tests_output/nightwatch-html-report/index.html

 ✖ SyntaxError
  Cannot use import statement outside a module
   
  In order to be able to load JSX files, one of these plugins is needed:
  - @nightwatch/react
  - @nightwatch/storybook (only if using Storybook in your project)
     

   Try fixing by :
   1. Using ES6 import/export syntax? - make sure to specify "type=module" in your package.json or use .mjs extension.

   Read More : 
   https://nodejs.org/api/esm.html 

Versions:

"@nightwatch/storybook": "^0.1.15",
"nightwatch": "^3.1.3",
"storybook": "^7.4.2",
@acha5066
Copy link
Author

I traced it to the object not having an elements key in the readParams method of csf.js

function readParams(obj, acc = {}) {

  if (Array.isArray(obj.properties)) {
    obj.properties.forEach(prop => {
      if (prop.value && prop.key) {
        if (Array.isArray(prop.value.properties)) {

          acc[prop.key.name] = prop.value.properties.reduce((prev, prop) => {
            if (prop.value.value) {
              prev[prop.key.name] = prop.value.value;

              return prev;
            }

            prev[prop.key.name] = prop.value.elements.map((element) => {
              const item = element.properties.reduce((elementPrev, elementProp) => {
                elementPrev[elementProp.key.name] = elementProp.value.value;

                return elementPrev;
              }, {});

              return item;
            });

            return prev;
          }, {});

        } else {
          acc[prop.key.name] = prop.value.value;
        }

      }
    });
  }

but no idea why it's not present.

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