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

cannot destructure property 'type' or 'node' as it is undefined #344

Open
schmod opened this issue Feb 2, 2022 · 2 comments
Open

cannot destructure property 'type' or 'node' as it is undefined #344

schmod opened this issue Feb 2, 2022 · 2 comments

Comments

@schmod
Copy link

schmod commented Feb 2, 2022

ESLint: 8.8.0

TypeError: Cannot destructure property 'type' of 'node' as it is undefined.
Occurred while linting /Users/schmod/myCode/myTest-unit.ts:118
Rule: "ava/assertion-arguments"
    at isString (/Users/schmod/myCode/node_modules/eslint-plugin-ava/rules/assertion-arguments.js:206:9)
    at /Users/schmod/myCode/node_modules/eslint-plugin-ava/rules/assertion-arguments.js:294:10
    at /Users/schmod/myCode/node_modules/enhance-visitors/index.js:25:12
    at /Users/schmod/myCode/node_modules/enhance-visitors/index.js:15:7
    at ruleErrorHandler (/Users/schmod/myCode/node_modules/eslint/lib/linter/linter.js:1107:28)
    at /Users/schmod/myCode/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/schmod/myCode/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/schmod/myCode/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/Users/schmod/myCode/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
error Command failed with exit code 2.

Cleaned-up version of the relevant test:

test('a test', async (t) => {
    const tests: Test[] = []
      [
        'returns null when blah blah blah',
        'val1',
        'val2',
        () => makeSomeMocks()
      ],
    ];
  
    await pEachSeries(tests, async ([testName, val1, val2, mocks]) => {
      const testSubject = await getTestSubject();
      t.is(testSubject.aFunction(val1), val2, testName);
      if (mocks != null) mocks.reset();
    });
  });
@novemberborn
Copy link
Member

Is it expecting testName to be a string, and blowing up because it's a variable? What happens if you turn it into a string?

@schmod
Copy link
Author

schmod commented Sep 14, 2022

Sorry for the very late update, but this indeed works if I wrap testName in a template literal (ie. ${testName})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants