Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suddenly TypeError: Invalid URL #8364

Open
arvedjo opened this issue Jan 22, 2025 · 1 comment
Open

Suddenly TypeError: Invalid URL #8364

arvedjo opened this issue Jan 22, 2025 · 1 comment
Labels
STATE: Need response An issue that requires a response or attention from the team. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@arvedjo
Copy link

arvedjo commented Jan 22, 2025

What is your Scenario?

I cannot start a test with a test.page method anymore.

What is the Current behavior?

An error gets thrown with:

ERROR Cannot prepare tests due to the following error:

TypeError: Invalid URL
at Object.

What is the Expected behavior?

The test starts

What is the public URL of the test page? (attach your complete example)

does not apply

What is your TestCafe test code?

import { Selector } from "testcafe";

fixture`Test.page`.page`http://devexpress.github.io/testcafe/example`;

test.page`http://devexpress.github.io/testcafe/blog/`("My test", async () => {
  // Starts at http://devexpress.github.io/testcafe/blog/
});

Your complete configuration file

module.exports = {
  baseUrl: "http://devexpress.github.io",
};

Your complete test report

testcafe chrome 'test.js'
ERROR Cannot prepare tests due to the following error:

TypeError: Invalid URL
at Object. (C:\Users\arhess.gitlab\testcafe\testcafe-uzh-kwf\temp\test.js:3:24)

Type "testcafe -h" for help.

Screenshots

Image

The t.testRun.test.baseUrl entry also seems to be corrupted.

Steps to Reproduce

  1. When adding baseUrl to the config file, the error appears. When leaving it out there is no error

TestCafe version

3.7.1

Node.js version

v20.18.2

Command-line arguments

testcafe chrome test.js

Browser name(s) and version(s)

Chrome 132.0.6834.84

Platform(s) and version(s)

Windows

Other

This problem might have occurred with a node update. Before, everything worked fine.

@arvedjo arvedjo added the TYPE: bug The described behavior is considered as wrong (bug). label Jan 22, 2025
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 22, 2025
@arvedjo
Copy link
Author

arvedjo commented Jan 25, 2025

I found out that in windows path.join("http://devexpress.github.io") outputs '.\\http:\\devexpress.github.io' in unix based 'http:/devexpress.github.io'.

Maybe this causes the error as in "test-page-url.js" these lines seem to produce invalid urls:

function prepareBaseUrl(url) {
    url = (0, path_1.join)(url, '/');
    return isAbsolute(url) ? (0, url_1.pathToFileURL)(url) : new url_1.URL(url);
}

Just tried it with Node v21.7.3 in Windows and error is gone. This seems to be a Version specific behaviour of node...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Need response An issue that requires a response or attention from the team. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

1 participant