The combination of Typescript, Gulp, and Protractor has resulted in a module error: "Module config.js

I have been experiencing some issues while trying to run Protractor using Gulp. The first two tasks are running smoothly, but when attempting to run the third task, it fails to locate the config.js file stored in the following path on my Windows system:

F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\config\config.js

gulpfile.js

import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';

gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
    console.log('About to run the specs...........')

    gulp.src(['ConvertedJSFiles/specs/*.js']).pipe(protractor.protractor({
            configFile: 'ConvertedJSFiles/config/config.js'
    })).on('error',function(e){
            throw e;

    });
});
console.log(protractor.getProtractorDir() + ' is the protractor directory ***');

Console Error

F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build>gulp run-prot
F:\Selenium2\Protractor\TypeScriptProject\node_modules\.bin is the protractor directory ***
[18:16:17] Using gulpfile F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js
[18:16:18] Starting 'run-prot'...
About to run the specs...........
[18:16:18] Finished 'run-prot' after 106 ms
[18:16:20] E/configParser - Error code: 105
[18:16:20] E/configParser - Error message: failed loading configuration file ConvertedJSFiles/config/config.js
[18:16:20] E/configParser - Error: Cannot find module 'F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\Convert
edJSFiles\config\config.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at ConfigParser.addFileConfig (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\configParser.js:125:
26)
    at Object.initFn [as init] (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\launcher.js:93:22)
    at Object.<anonymous> (F:\Selenium2\Protractor\TypeScriptProject\node_modules\protractor\built\cli.js:112:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

F:\Selenium2\Protractor\TypeScriptProject\ConvertedJSFiles\build\gulpfile.js:11
        throw e;
        ^
Error: protractor exited with code 105

Answer №1

The issue stemmed from an incorrect directory reference. I was able to pinpoint the problem using the "path" package. Here is the updated file:

import * as gulp from 'gulp';
import * as protractor from 'gulp-protractor';
import * as path from 'path';
gulp.task('webdriver-update', protractor.webdriver_update);
gulp.task('webdriver-standalone', protractor.webdriver_standalone);
gulp.task('run-prot', function () {
    console.log('Preparing to execute the specs...........')
    let srcfiles=path.resolve('../specs/*.js');
    console.log(srcfiles);
    gulp.src([srcfiles]).pipe(protractor.protractor({
            configFile: '../config/config.js'
    })).on('error',function(e){
            throw e;

    });
});
console.log(protractor.getProtractorDir() + ' is the current protractor directory ***');

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

Deactivate the button when the length is less than x

Hey there! I'm new to JavaScript and I'm working on replicating a specific webpage. On this page, there's a button that should be disabled if the login form doesn't have at least 11 characters for the user input and 8 characters for the ...

Determine the status of a script in PHP by incorporating AJAX

I am having trouble with my file upload page in the application. I want to display "Uploading" while the file is uploading and then show "Processing" while the file is being processed. Eventually, after the script completes, my page should redirect to a sp ...

Is the size of the JSON file inhibiting successful parsing?

After retrieving a large list of schools with their respective columns from the database, totaling over 1000 rows, I converted it to JSON and passed it to my view. I then attempted to parse it using $.parseJSON('@Html.Raw(Model.subChoiceJsonString)& ...

Scroll through the div to quickly find the relevant content

I have implemented the following HTML structure: <div style="height:200px;overflow-y:scroll;"> <table>.....</table> </div> By using this setup, I am aiming to replicate the functionality of an expanded <select> control wit ...

express-validator not providing any feedback from endpoint when integrated with TypeScript

I've been working on validating the response body for my endpoint, but I'm running into an issue where I'm not getting a response from that endpoint when using express-validator. I'm confident that I have followed the official documenta ...

The "session expire=null not working" issue persists with Google Chrome

Based on the documentation for Connect, sessions are expected to expire when the browser is closed: By default, the cookie.maxAge parameter is set to null, making the cookie a browser-session cookie. When the user closes their browser, the cookie (and s ...

Navigating through various versions of admin-on-rest can be perplexing

This question is likely directed towards maintainers. Currently, I am using the stable version of admin-on-rest (https://www.npmjs.com/package/admin-on-rest) which is at 1.3.4. It seems that the main project repository is only receiving bug fixes, while ...

Adjust the height to match the shortest sibling child div height

In my layout, I have multiple rows with each row containing multiple columns. Within each column, there is a div and a paragraph - the div contains an image. My goal is to set the div with the class cover-bg to the lowest height of cover-bg in the same row ...

How can I extract the directory path from a string that includes a file name in Node.js?

Working with multiple files in Node and trying to figure out a way to extract the file name from the directory path without depending on external packages. Is there a built-in solution in Node for this, or do I need to resort to using something like Filena ...

Creating an easy-to-update catalog utilizing an external file: A step-by-step guide

I am looking to create a product catalog with 1-4 products in a row, each displayed in a box with details and prices. I would like to be able to generate the catalog easily using an XML/CSV file that can be updated. Can anyone provide guidance on how to ac ...

Notifying Incorrect Reading on Slider Display

My slider is supposed to alert the output on a button click based on its value, but it always alerts 2 instead of the expected values of 1, 2, 3, or 4. Here is the code I am using: var chanceoflive3; var inputElement = document.querySelector('.rang ...

issues with search functionality in angular

Just diving into the world of angular and struggling with implementing a 'live search' functionality. I've stored my JSON data as a variable in a JavaScript file and successfully displayed it in the HTML. I also have a 'list' radio ...

JavaScript function executes before receiving AJAX response

Within my code, there is an AJAX function named flagIt() that gets triggered by another function called validateForm() upon submission. The validateForm() function is responsible for form validation. function validateForm(){ var error = ""; //perf ...

Modifying an HTML attribute dynamically in D3 by evaluating its existing value

I'm facing a seemingly simple task, but I can't quite crack it. My web page showcases multiple bar graphs, and I'm aiming to create a button that reveals or conceals certain bars. Specifically, when toggled, I want half of the bars to vanish ...

The Popover fails to attach itself to the element that triggered it

It appears that my Twitter Bootstrap popovers are experiencing positioning issues when the triggering element is inside a container with the style -ms-overflow-y: auto; (a scrollable element within the window). As I scroll the element, the popover does no ...

Guide on redirecting to a different page and showing a flash message in Next.js

Currently working on Reactjs and nextjs, my goal is to submit a form using axios(Api). The form submission is successful, but I would like the page to change after submitting the form (displaying Allblogs.js, similar to a redirect) along with a flash mes ...

The dark mode feature in my Mac project is essential. I am currently leveraging Next.js alongside React and TypeScript

Struggling to implement dark mode in my Mac project. Utilizing Next.js with React and TypeScript, but can't seem to get it right. I've attempted the following methods without success. Any suggestions? const config: Config = { plugins: [ re ...

Executing the collection.find() function triggers an internal server issue and eventually leads to a timeout error

My ExpressJS backend was running smoothly with hardcoded data, but when I integrated MongoDB into the system, my requests for data started timing out. I added a record to a collection using the command prompt: > db stackmailer > db.sites.find() { ...

JavaScript: developing an algorithm to identify and eliminate duplicate strings

Consider the following JS array: 0 - Star Wars: A New Hope 1 - Star Wars: The Empire Strikes Back 2 - Star Wars: Return of the Jedi 3 - Star Wars: A New Hope (1977) 4 - Star Wars: Return of the Jedi (1983) 5 - Star Wars: Attack of the Clones 6 - Star Wars ...

Collaborating on a TypeScript typing file that includes a universal type for all cases

I have been delving into an existing TypeScript typing file, despite my limited experience in creating them. While some types make sense to me, like contactId: undefined | string Populate(id: undefined | string, referenceType: ReferenceType): void I have ...