Having trouble converting TypeScript to JavaScript, and encountering difficulty locating the 'protractor' module

I'm facing an issue with compiling TypeScript to JavaScript because I can't find the module 'protractor'. Despite having Protractor, TypeScript, and Jasmine installed locally with their respective types.

Here is the structure of my project: - src - projects/protractor - projects/tests - projects/pages (import { ElementFinder, browser, element, by, protractor } from 'protractor';) - specs

In my tsconfig.js file:

{
    "compilerOptions": {
        "sourceMap": false,
        "target": "es6",
        "moduleResolution": "node"
        "baseUrl": ".",
         "paths": {
             "protractor": [
                 "./projects"
             ]
         },
         "traceResolution": true
    },
    "module": "commonjs",
    "include": [
        "./Swc.Portal.Site/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ]
}

And in my protractorConf.js file:

exports.config = {
    seleniumServerJar: 'node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-2.47.1.jar',
    chromeDriver: 'node_modules/chromedriver/chromedriver',
    allScriptsTimeout: 20000,

    capabilities: {
        'browserName': 'chrome'
    },

    framework: 'jasmine2',

    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 90000
    },

    onPrepare: function() {
        var specs = browser.params.specs;
        let globals = require('protractor');
        let browser = globals.browser;
            browser.driver.manage().window().maximize();
    }
};

The challenge I'm currently facing is that I cannot place the protractor module in the same directory as the tests, so I need to resolve the import issues related to non-relative paths.

Answer №1

Your path to protractor is incorrect. When installing it locally, the protractor package should be located within the /node_modules directory at the root of your project. Here is an example structure:

my_project/node_modules/protractor

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

What is the minimum required node.js version for my project to run?

Is there a command in NPM that can display the minimum required Node version based on the project's modules? ...

Does anyone know of a JavaScript function that works similarly to clientX and clientY but for tooltips when the mouse moves?

When using plain JavaScript to create a function that moves a tooltip on mouse move, the function works the first time with clientX and clientY, but fails to work when repeated. What could be causing this issue with clientX and clientY? Any suggestions on ...

How to format numbers in JavaScript post calculations

Struggling to find a solution to format calculation results with commas for thousand separators (e.g., 10,000). After implementing the .toLocaleString('en-US', {maximumFractionDigits:1}); method to format numbers in the output, I encountered unex ...

Is it possible in Vue.js to create a reactive functionality for a button using a watcher for "v-if" condition?

I have a userlist page with various profiles, including my own. A button is supposed to appear only when viewing my own profile. The issue arises when switching from a different profile to my own (changing the router parameter) - the button should show up ...

Can you explain the significance of Angular 2 hashtags within a template?

Currently exploring Angular 2 and stumbled upon the following code: <input #searchBox (keyup)="search(searchBox.value)" Surprisingly, it works! Despite its functionality, the significance of #searchBox eludes me. Extensive research in the documentati ...

What is the most effective method for flipping a THREE.Sprite in r84?

After updating my game engine from r69 to r84, I encountered a few issues. One of them is related to flipping sprites. In the past, I could easily flip sprites using the following code: sprite.scale.x = -1; Unfortunately, this method no longer works in ...

What's the best way to maintain the return type of a function as Promise<MyObject[]> when using forEach method?

I am currently working with a function called search, which at the moment is set up to return a type of Promise<MyObject[]>: export function search(args: SearchInput) { return SomeInterface.performSearch(args) .then(xmlRequest =&g ...

Changing the style of characters within a contenteditable element

Seeking advice on how to implement an input element that changes style (like font color) between two specific characters (such as '[' and ']'). I'm considering using a contenteditable div but open to other suggestions. Currently ex ...

Defining the type of the createAction() function in TypeScript within the context of Redux Toolkit

Lately, I have been delving into the redux-toolkit library but I am struggling with understanding the type declaration of the createAction function as demonstrated below. The createAction function returns a PayloadActionCreator which includes a generic of ...

Ways to change a value in an array within MongoDb

My array value is being overridden by $set, how can I update it properly? var obj = // contains some other data to update as well obj.images=images; // updating obj with images [] Units.update({_id: 'id', {$set: obj}); Ultimately, my MongoDB ...

Adjustable height and maximum height with overflow functionality

Currently, I am in the process of developing a task manager for my application and facing an obstacle when trying to calculate the height of a widget. My goal is to determine the maximum height (assuming a minimum height is already set) by subtracting a ce ...

When set to synchronize:true in Typeorm, any changes to an entity will result in the many-to

As a newcomer to typeorm, I've encountered a peculiar issue with the synchronize: true setting in my ormconfig.js. Whenever I make changes to an entity with a Many-to-Many relationship, any data present in the join table prior to the entity modificati ...

What is the best way to implement multiple templates for a single component?

Is there a way to configure my Home Component based on the user's role? For instance: If the employee is an admin, then the home component should load the template URL designed for admins. Likewise, if the employee is a cashier, then the home compo ...

How can you use jQuery to select and manipulate a wildcard href ID?

There are multiple links listed below: <a href="http://www.google.com" id="link01">Google</a> <a href="http://www.yahoo.com" id="link02">Yahoo</a> <a href="http://www.cnn.com" id="link03">CNN</a> <a href="http://www. ...

Increasing variable in angular template (nested ng-repeat)

I am facing a similar situation as described in the example below, and I need to generate a serial number for each row independently for each mark record. Here is the Java script Object structure: $scope.childsList = [ { id:12346, ...

Set the background color of the Material UI Drawer component

Need some advice on changing the background color of Material UI's Drawer. I've attempted the following approach, but it's not producing the desired result. <Drawer style={customStyle} open={this.state.menuOpened} docked={false} ...

Steps to send an object array using a promise

I've put in a lot of effort but haven't found a solution that works well for me. I attempted using promise.all and setting the array globally, but it didn't work out. My goal is to search through three MongoDB collections, match the finds, ...

Decorator used in identifying the superclass in Typescript

I am working with an abstract class that looks like this export abstract class Foo { public f1() { } } and I have two classes that extend the base class export class Boo extends Foo { } export class Moo extends Foo { } Recently, I created a custom ...

Guide to resolving a Promise that returns an array in TypeScript

My goal is to retrieve an array in the form of a promise. Initially, I unzipped a file and then parsed it using csv-parse. All the resulting objects are stored in an array which is later returned. Initially, when I tried returning without using a promise, ...

Leveraging functions in a Node.js module

I am struggling with using a function inside a Node.js module. I have implemented a custom sorting function to sort an array of objects based on the value of a specific property. exports.getResult = function(cards) { cards.sort(sortByField('suit& ...