0

I'm trying to set up an e2e test suite with specs (it) to test opening a file in the application. I'd like to gather some performance data later on each test spec (based on file size, time, etc.).

Since the test specs are pretty much the same except for the files and related properties, I used a json object (array of data) to fetch the filenames. I tried to use the solution listed here.

I tried to iterate throught the test specs using jasmine-data-provider as mentioned here . But the specs get skipped.

describe("App File Open", () => {
let fileNames: string[] = [];
const filePath: string = "common filepath for files"
  beforeAll(() => {        
    fileNames = jsonFile["files"];     

    // ...
  });

  beforeEach(function (): void {        
    // ...
  });

  using(fileNames, (data: string) => {
    it("open file " + data, () => {
      // ...
      inputElement.sendKeys(filePath + data);
      // ...
    });
  });

  afterEach(function (): void {
    // ...
  });

  afterAll(function (): void {
    // ...
  });
});

The test skips through the blocks without picking up the test specs (it).

"Jasmine started

Executed 0 of 0 specs SUCCESS in 0 sec."

Is it possible to loop through specs? If so, what am I missing here? (Apologies if this is a duplicate)

Samyth
  • 3
  • 2

1 Answers1

1

I don't know jasmine-data-provider but this block

using(fileNames, (data: string) => {
    it("open file " + data, () => {
      // ...
      inputElement.sendKeys(filePath + data);
      // ...
    });
  });

is evaluated before fileNames = jsonFile["files"];, so fileNames is an empty string.

HTN
  • 3,388
  • 1
  • 8
  • 18