alsatian icon indicating copy to clipboard operation
alsatian copied to clipboard

Not checking whether exported members are constructors

Open jamesadarich opened this issue 6 years ago • 0 comments

As noted in #197 looks like there is also a case that a function can be exported in a fixture file and we attempt to construct this. Need to do an additional test to check whether it's newable or try catch.

Below is the offending code in test-loader.ts

      if (typeof testFixtureModule === "function") {
        // if the default export is class constructor
        loadFixture(testFixtureModule, testFixtureModule.name);
      } else {
        // otherwise there are multiple exports and we must handle all of them
        Object.keys(testFixtureModule)
          .filter(key => typeof testFixtureModule[key] === "function")
          .forEach(key => loadFixture(testFixtureModule[key], key));
      }

jamesadarich avatar Oct 18 '18 22:10 jamesadarich