-2

I got this error while testing, ReferenceError: type is not defined how to resolve it ?? but there is no variable named "type" here.

jestExpect(sample.datasource-type).toEqual('metadata');

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Please update your question to include a [Minimal, Complete, and Reproducible](https://stackoverflow.com/help/minimal-reproducible-example) code example, clear error message details, and stacktrace, debugging information, etc... – Drew Reese Sep 09 '20 at 06:07
  • check now. i have updated the question – Dhaya Mohan Sep 09 '20 at 06:11
  • 1
    not sure who closed it but it is very easy to reproduce and is not a typo but as I said a quirk of how the dot notation works in JS with regard to arbitrary properties on JS objects. – adz5A Sep 09 '20 at 08:58

1 Answers1

2

Javascript does not accept hyphens in identifiers. You need to replace sample.datasource-type with sample["datasource-type"]

adz5A
  • 2,012
  • 9
  • 10