Issue encountered: Module 'jasmine-expect' not found [Protractor]

I am facing an issue while trying to execute a protractor test that connects to my application.

Upon running the command (git bash/terminal):

   protractor conf.js

An error is displayed as follows: "

Error: Cannot find module 'jasmine-expect'

To resolve this, I proceeded to install the required module:

npm install -g jasmine-expect

However, even after installation, the failure persists.

Below is the snippet of my test script:

describe('DragAndDrop Test', function () {
require('protractor');
require('jasmine-expect');


beforeAll(function () {
    context = new Context();
    context.get();
    browser.waitForAngular();
    browser.driver.manage().window().maximize();
});

it('should drag and drop Application Experience tile', function () {

    //target is where we are dragging the box to. Box refers to the specific element
    var target = { x: 300, y: 50 };
    var box = element(by.cssContainingText('h3', 'Application Experience'));

    //scope will hold scope variables indicating box location
    //get the standardItems Scope

    box.evaluate('dashboards').then(function(scope) {
        //ensure initial position of box in column 0 and Row 0
        expect(scope['1'].widgets[0].col).toEqual(0);
        expect(scope['1'].widgets[0].row).toEqual(0);
    });

    //perform drag and drop action on the box
    browser.actions().dragAndDrop(box, target).perform();
    browser.waitForAngular();
    browser.driver.sleep(5000);

    //get updated scope post drag and drop
    box.evaluate('dashboards').then(function(scope) {
        //verify new position of box in column 1 and row 0
        expect(scope['1'].widgets[0].col).toEqual(1);
        expect(scope['1'].widgets[0].row).toEqual(0);
    });
});

});

var Context = function () {
this.ignoreSynchronization = true;
    //load the website
    this.get = function () {
        browser.get('http://127.0.0.1:62734/index.html#/dashboard');
    };
};

Below is the content of my conf.js file:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['gridster-Test.js'],
    capabilities: {
    browserName: 'firefox'
   }
};

Seeking suggestions for resolving this issue?

Answer №1

To start, attempt to install the package without using the -g option:

npm install jasmine-expect

Additionally, transfer the require('jasmine-expect'); statement from within the describe block to the onPrepare() function in your Protractor configuration file:

onPrepare: function () {
    require("jasmine-expect");
},

Answer №2

Make sure to include the dependency in your package.json file.

npm install jasmine-expect --save-dev 

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

Hide the menu when tapping outside on a tablet device

Currently working with HTML, CSS, and JS (specifically Angular) I have a Header menu that contains dropdown sub-menus and sub-sub-menus in desktop view. On a PC, the sub-menus appear on hover and clicking on an entry redirects you somewhere. Clicking o ...

A step-by-step guide on updating a deprecated typings package manually

Currently, I am developing a NodeJS application using TypeScript and incorporating numerous Node packages. However, not all of these packages come with TypeScript definitions, so Typings is utilized to obtain separate definition files. During the deployme ...

Be cautious of peer dependencies notifications when executing npm install

Currently, I am in the process of updating my React/Firebase project by executing: npm install --save firebase-functions@latest Unfortunately, during this update, several warnings have emerged: npm WARN <a href="/cdn-cgi/l/email-protection" class="__ ...

Tips for handling an incorrect date entry when a field loses focus in AngularJS

If I have an <input> field with the type='date' attribute in its untouched state, it displays mm/dd/yyyy as the date format. I am looking to see if there is a way to utilize AngularJS ng-blur directive to reset the field to this original fo ...

Automate downloading files from Internet Explorer and saving them to a specified directory using AutoIT

I am facing a requirement to download a file from Internet Explorer 11 and save it to a specific location using Selenium and AutoIT. The path where the file should be saved is provided through the command line. Below is the code I have implemented: ; Get ...

Encountering a TypeScript error during Docker build causing npm run build to fail

Compilation Error. /app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts TypeScript error in /app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts(2,13): '=' expected. TS1005 1 | import * as React from 'react' ...

Implement an event listener to detect incoming SMS messages using the mozMobileMessage API within the Boot to Gecko (B

As part of a university assignment, I have embarked on the journey of learning how to develop apps using AngularJS for Firefox OS. This marks my maiden voyage into the realm of JS app development. The primary objective of this app is to execute commands t ...

Encountering difficulties importing the angular datepicker feature into my application

I have been attempting to integrate the angular-ui-bootstrap datepicker into my application but I am encountering difficulty in doing so. As part of this process, I am using ES6 and below is the code structure I currently have set up: map/src/app.js imp ...

Suggestions for managing AngularJS within ASP.NET Web Forms?

Recently, I integrated AngularJs into a website that is built with asp.net webforms. I discovered that when using ng-Submit on a button, the form also triggers a Post call. How can I prevent the form from automatically submitting so that Angular can perf ...

Enhancing the node module of a subpackage within Lerna: A step-by-step guide

I recently integrated lerna into my workflow to streamline the installation of all node modules for multiple sub packages with just one command. Currently, I'm only utilizing the lerna bootstrap feature. Here's a snippet from my lerna.json: { & ...

Organize data in a table using a dropdown selection menu

My data structure looks like this: $scope.friends = [ { name:'John', phone:'555-1212', age:10 }, { name:'Mary', phone:'555-9876', age:19 }, { name:'Mike', phone:'555-4321', age:21 }, { na ...

The .npmrc file located within the project directory and the user directory

I am currently juggling multiple projects, all of which require the same .npmrc file except for one. For this particular project, I need to use a different .npmrc file. I have configured the .npmrc in my user folder ('C:/Users/me/.npmrc') and e ...

Fetching information with request query parameters in Node.js

Working on implementing email verification using nodemailer for user sign-ups. The process involves sending out an email containing a link (usually something like localhost:3000/verify/?id=##). After the user clicks the link, I can see that a GET request ...

The process of installing dependencies recursively using pnpm

In my monorepo project, I have workspaces A and B. Workspace A depends on B being built first, with each workspace in its own folder as defined in pnpm-workspace.yaml packages: - 'src/mydepa' - 'src/mydepb' { "name": &qu ...

Encountering issues when integrating AngularUI with Bootstrap 3 wiring

I've been struggling to integrate AngularUI with Bootstrap 3 without success. I copied the necessary AngularUI code from the bootstrap 3 branch found here: https://github.com/angular-ui/bootstrap/tree/bootstrap3_bis2 For my first attempt, I decided t ...

When the button is clicked, automatically sync data from a website to update a Google Sheets spreadsheet

I am a frequent Betfair user and I meticulously track my bets in a Google Sheets spreadsheet. The manual entry of bet information is time-consuming. I am exploring the idea of automatically extracting bet details from the Betfair website when clicking on ...

Automate login process on Selenium web driver without storing the password directly in the code

Is there a way to log in to an application using Selenium webdriver without storing the password directly in the code? Additionally, I am looking to conceal the 'geckodriver.exe window' while the script runs. from selenium import webdriver from ...

What is the best way to connect a globally installed node package to a project using yarn?

I'm new to using yarn and I'm having trouble connecting a globally installed package to my project. When using npm, I would typically run npm link <package-name> but this doesn't seem to work with yarn. Whenever I try running yarn link ...

Setting up Node.js 10 and npm on an Alpine Linux system

I am currently using Alpine to construct my Rails application and I am encountering complications with some of its dependencies. At this moment, here is my Dockerfile configuration: FROM ruby:2.5.1-alpine ENV BUNDLER_VERSION=2.0.2 RUN apk add --update - ...

Exploring the seamless integration of npm and Docker in Laravel

I have implemented a docker configuration similar to the one provided here for my Laravel project. Within my docker-compose.yml, I have defined a custom npm service: npm: image: node:14.6 container_name: npm-memberportali volumes: - .:/v ...