stalniy / bdd-lazy-var

Provides UI for testing frameworks such as mocha, jasmine and jest which allows to define lazy variables and subjects.
MIT License
162 stars 14 forks source link

TypeError: Cannot read property 'Symbol(__lazyVars)' of undefined #43

Closed nzacca closed 6 years ago

nzacca commented 6 years ago

Hello!

Great library! We ran into the above error recently and we're not sure why or what the cause might be.

This occurs on v2.2.3 on line https://github.com/stalniy/bdd-lazy-var/blob/master/getter.js#L126

It appears that the context is undefined when it is passed from here: https://github.com/stalniy/bdd-lazy-var/blob/master/getter.js#L534

The issue appears to be that if the this.state.contexts is empty, this.currentContext is returning undefined which leads to the above error. https://github.com/stalniy/bdd-lazy-var/blob/master/getter.js#L545

Hopefully this is an easy fix.

Cheers!

Update: Just noticed that this appears to occur when we have a suite that does not use any def definitions. If we set the test focus to only the suites with def variables defined then everything works as expected.

nzacca commented 6 years ago

Fixed this issue. Sorry for the erroneous report.

In case anyone else was having this same issue, here's what I did to resolve:

  1. Add entry in tsconfig.json as per the instructions in the files property:
  2. Add entry in karma.conf.js as per the instructions in the files property:
  3. Removed the import { get, def } from "bdd-lazy-var/getter" in my spec files.
    • this is not needed if you use the above two config settings.

I inadvertently added the getter definitions to the include instead of the files previously which led to the error reported.