Running a loop to utilize data from an array of objects within a Protractor it() spec

I am currently in the process of setting up an end-to-end test suite with specifications to assess the functionality of opening a file within the application. My goal is to collect performance data for each test specification, focusing on variables such as file size and time.

Given that the test specifications share similar structures, with variations only in terms of files and associated properties, I have utilized a JSON object (an array of data) to retrieve the file names. I attempted to implement a solution recommended here.

I endeavored to iterate through the test specifications using jasmine-data-provider, following guidance provided here. However, the specifications seem to be skipped during execution.

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 testing process appears to skip over the blocks without recognizing the test specifications (it).

"Jasmine started

Executed 0 of 0 specs SUCCESS in 0 sec."

I am wondering if there is a way to successfully loop through the specifications. If so, could someone kindly point out what might be missing here? (I apologize if this question has been addressed before)

Answer №1

I am not familiar with jasmine-data-provider, however, the following code snippet caught my attention

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

This block is executed prior to fileNames = jsonFile["files"];, resulting in fileNames being an empty string.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trouble with Jest when trying to use route alias in Next.js with Typescript

Currently, I am developing a Next.js App (v13.2.3) using Typescript and have set up a path alias in the tsconfig.json. Does anyone know how I can configure the jest environment to recognize this path alias? // tsconfig.json { "compilerOptions": ...

Tips on converting a date string in the format 'dd/MM/yyyy' to a date type using TypeScript

I have attempted the following code in order to convert the date from 'yyyy-mm-dd' format to 'dd/MM/yyyy'. However, when I check the typeof() of the result, it shows that it is a string. Is there a method to convert it into only a date? ...

Exporting stylesheets in React allows developers to separate

I am trying to figure out how to create an external stylesheet using MaterialUI's 'makeStyles' and 'createStyles', similar to what can be done in React Native. I'm not sure where to start with this. export const useStyles = m ...

The execution time of Node's Promises.all() function is unreasonably slow

I need to add a table containing data on sent emails after each email has been successfully sent. Within a loop, I am populating an array to be resolved using the Promise.all(). insertData is a function that adds data, requiring two parameters: connector, ...

Ensuring the inclusion of library licenses in the production build is a crucial step

We have numerous dependencies (node_modules) in our Angular app, which are typically licensed under Apache 2.0 or MIT. From my understanding of the licenses, the production build is considered a "derived work" and we are required to include copyright notic ...

Using Angular 2 to submit ngModel data within an ngFor loop

When submitting the form, an error occurs when trying to repopulate the data back to the form: ERROR TypeError: Cannot read property 'id' of undefined This is in reference to the code snippet: <select [(ngModel)]="insurer.group.id" name="grou ...

Error: Unable to locate App.js file upon transition to Typescript

I'm in a bit of a bind with my Laravel project and I'm struggling to find a solution. I recently tried to upgrade from vue2 to vue3 with typescript, following this tutorial for the vue upgrade and this tutorial for typescript integration. However ...

Tips for enhancing Mui 5 Typography using personalized properties (TypeScript)

I am attempting to include a custom property in Mui's Typography component: using module augmentation: // mui.d.ts declare module "@mui/material/Typography" { interface TypographyProps { opacity: string | number; } } with theme co ...

A step-by-step guide on integrating @angular/platform-browser with a material pop up dialog

Having trouble setting up a user list in a material design popup? Getting an error that says, "Can't bind to 'ngForOf' since it isn't a known property of 'ion-list'?" After some digging, it seems like the issue stems from not ...

Retrieve the keys of an interface using generic methods

Recently, I encountered a challenge with a function that utilizes generics. The specific generic in question is <T extends anInterfaceName>. Struggling to retrieve the keys of the interface used in T within the function, my quest for a solution led m ...

What causes a compile-time error in visual code when using generics with multiple types?

I'm attempting to develop a function with a generic type that takes one parameter with multiple types. It seems straightforward, but when I combine certain types, I encounter compile-time issues in Visual Studio Code. Check out my example below: Th ...

Is it possible to access the generic type that a different generic type inherits in TypeScript?

I've developed an interface specifically designed for types capable of self-converting to IDBKey: interface IDBValidKeyConvertible<TConvertedDBValidKey extends IDBValidKey> { convertToIDBValidKey: () => TConvertedDBValidKey; } My goal n ...

Remove all keys of type BaseType from objects that are children of BaseType

There are two types: BaseType and BabyType. export type BaseType = { id: string } export type BabyType = BaseType & { name: string }; In a generic layer where <T extends BaseType> is used, the item being dealt with is actually a 'B ...

Exploring the Power of Map with Angular 6 HttpClient

My goal is to enhance my learning by fetching data from a mock JSON API and adding "hey" to all titles before returning an Observable. Currently, I am able to display the data without any issues if I don't use the Map operator. However, when I do use ...

Exploring the attributes of optional features

Dealing with optional properties can be quite tedious. Consider the object test1 in TypeScript: interface Test { a?: { b?: { c?: { d?: string } } }; } const test1: Test = { a: { b: { c: { d: 'e' } } } }; Handling the absence of each proper ...

Visual Studio 2015 is struggling to locate a specific module, yet the command line interface for

Recently, I delved into the world of TypeScript in VS2015 and so far, it has been a smooth journey. I managed to establish a structure that compiled and performed as anticipated. However, things took a turn when I attempted to incorporate npm-installed mo ...

Discovering the current page using ons-navigator in Onsen UI

I am currently attempting to determine the page I am on while using the popPage() function with Onsen UI's ons-navigator. I have tried the following methods, but they always return false regardless: this.navigator.nativeElement.popPage().then((page: a ...

The Typescript interpreter failed to load because the module 'ts-node/register' could not be found

I am facing an issue with my Node.js API deployed using pm2. After deployment, I encounter the following error: Failed to load Typescript interpreter: Cannot find module 'ts-node/register' Require stack: - /usr/local/lib/node_modules/pm2/lib/Pro ...

Refresh the context whenever the state object changes

Within my application, I am utilizing a PageContext to maintain the state of various User objects stored as an array. Each User object includes a ScheduledPost object that undergoes changes when a user adds a new post. My challenge lies in figuring out how ...

Set up linter rules that utilize `useEffect` in place of `React.useEffect` (utilizing named export rather than full export)

It's important in our codebase to always use: import { useEffect } from 'react'; instead of: import React from 'react'; // use in code as `React.useEffect` Can we enforce this rule with longer eslint rules? If so, how can we impl ...