The softAssert method is not available when trying to implement soft assertions within a TypeScript-based Protractor framework

Uncaught TypeError: assertion.softAssert is not a function

I recently included a package called soft-assert using npm in my project. To install this package, I executed the following command:

npm i soft-assert -g --save-dev

Incorporated the following code snippet:

 import * as assertion from "../../soft-assert/lib/assertion";

 await assertion.softAssert(await this.headerOversightrequirements.getText(), AdminPanelData.lblOversightRequirements, AdminPanelData.lblOversightRequirements,[]);

 await assertion.deepAssert(await this.headerAdminPanel.getText(), AdminPanelData.lblAdminPanel, header is displayed,[]);

I am utilizing protractor as an automation framework, with cucumber for BDD, typescript as the scripting language, and npm for managing dependencies. Despite the function being present when inspecting the code in the node_module/soft-assert package where it was installed, I keep encountering this error message. I have examined the method implementation but still cannot figure out why this issue persists. The error occurs as soon as the script reaches the line where the soft/deep assert methods are implemented.

Answer №1

Is the positioning of the assertion import statement correct within my code? I have successfully used the following in my project located at the root level.

import * as assertion from "../lib/assertion"; 

assertion.softAssert({a:123}, {a:12}, "Failure error message 1", []);
assertion.softAssert({a:123}, {a:123}, "Failure error message 2", []);
assertion.softAssertAll();

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

Which is better: specifying Node.js version with nvmrc or in package.json engines

Ensuring that other developers working on my JavaScript project use specific versions of node and npm is important to me. I recently added the following code snippet to my package.json file: "engineStrict" : true, "engines": { "node" : "10.10.0", ...

Troubles arise when attempting to utilize yarn for my projects

Whenever I enter the command yarn start in the terminal, I get this output: yarn run v1.22.4 $ react-scripts start 'react-scripts' is not recognized as an internal or external command, operable program or batch file. error Command fai ...

Setting up a software from a GitHub source

My issue arises when attempting to install a particular package of mine with the version specified as a specific git branch. The problem occurs because the repository does not contain the dist folder, which is required by my npm package. Here is the metho ...

A JavaScript function written without the use of curly braces

What makes a function good is how it is declared: export declare class SOMETHING implements OnDestroy { sayHello() { // some code to say hello } } However, while exploring the node_modules (specifically in angular material), I stumbled up ...

The quantity of documents queried does not align with the number of data counts retrieved from Firestore

Facing an issue with calculating the Firestore read count as it keeps increasing rapidly even with only around 15 user documents. The count surges by 100 with each page reload and sometimes increases on its own without any action from me. Could this be due ...

Encountering authentication failure while trying to ship with FedEx using Node.js NPM package

Currently utilizing the shipping-fedex npm package and encountering no issues in sandbox mode. Successfully able to make shipping rate requests in production, however, facing an authentication failed error when attempting to send a ship request. What cou ...

What is the process to activate a function within a component once a service method has been run?

I'm currently working on a chart configuration using amCharts, where an eventListener is registered for the bullets. This event listener then triggers another function in my chart service. My goal is to activate a method in my component as soon as th ...

Create a list of items with checkboxes next to each that can be repeated using PdfMake

Incorporating pdfMake into my project, I am trying to display text next to an image and replicate this section in my docDefinition. The issue arises when I attempt to repeat this part using the following code snippet: { columns: [ { ...

Encountering a build error message while attempting to install the npm module karma

I am facing an error while attempting to install the Karma NPM module. I am unable to decipher the cause of the error and finding solutions via a Google search has proved unfruitful. Any insights or help on this matter would be greatly appreciated. > ...

Using TypeScript to Load JSON Data from a Folder

I'm a newcomer to TypeScript and encountering an issue. My task involves dynamically loading objects from a directory that houses multiple JSON files. The file names are generated through an export bash script populating the resource directory. I wan ...

What improvements can I implement in this React Component to enhance its efficiency?

Seeking advice on improving the efficiency of this React Component. I suspect there is code repetition in the onIncrement function that could be refactored for better optimization. Note that the maxValue prop is optional. ButtonStepper.tsx: // Definition ...

The guidelines specified in the root `.eslintrc.json` file of an NX workspace do not carry over to the project-level `.eslintrc.json` file

In my main .eslintrc.json file, I have set up some rules. This file contains: { "root": true, "ignorePatterns": ["**/*"], "plugins": ["@nrwl/nx", "react", "@typescript-eslint", &qu ...

Submitting a POST request from a Typescript Angular 2 application to a C# MVC backend

Having trouble passing a payload using Typescript service in an http.post request Here is my TypeScript code: saveEdits(body: Object): Observable<Animal[]> { let bodyString = JSON.stringify(body); let headers = new Headers({ 'Content- ...

What is the method for transmitting a URL API from an ASP.NET Core server to my Angular 2 single application?

Is there a way to securely share the url of the web api, which is hosted on a different server with a different domain, from my asp net core server to my client angular2? Currently, I am storing my settings in a typescript config file within my angular2 ap ...

Is this Firebase regulation accurate and suitable for PUT and GET requests in an Angular and Firebase environment?

Creating a system where users can only see their own posts and no one else can access them is my main goal. Authentication along with posting functionality is already in place and working, but I want to implement this without using Firebase restrictions. ...

Alter text within a string situated between two distinct characters

I have the following sentence with embedded links that I want to format: text = "Lorem ipsum dolor sit amet, [Link 1|www.example1.com] sadipscing elitr, sed diam nonumy [Link 2|www.example2.com] tempor invidunt ut labore et [Link 3|www.example3.com] m ...

Issue with running npm start due to conflicting versions of Babelloader

I have Npm installed on my MacOS, and I keep encountering an ELIFECYCLE error after running either npm run start or npm start. When running the commands, I get the following hints pointing to a project dependency tree issue: [0] It seems to be related to a ...

Guide on navigating to a specific page with ngx-bootstrap pagination

Is there a way to navigate to a specific page using ngx-bootstrap pagination by entering the page number into an input field? Check out this code snippet: ***Template:*** <div class="row"> <div class="col-xs-12 col-12"> ...

Angular library (enabling feature import support through the use of `import {a1} from 'my-lib/1a'`)

After following the official angular library documentation and reading various articles on the topic, I successfully created my own library. Everything seemed to be working fine except for one issue - I couldn't figure out how to import separate featu ...

Alert: React-Weather is causing an invalid element type in React

I am feeling overwhelmed. I have created a custom component called react-weather which has been installed using npm. Here is the code snippet for my self-written Weather.js component located in the src/components folder: import React, { Component } from & ...