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

Loading tests from URL - No test files found #214

Open
adventurist opened this issue Sep 16, 2024 · 3 comments
Open

Loading tests from URL - No test files found #214

adventurist opened this issue Sep 16, 2024 · 3 comments

Comments

@adventurist
Copy link

Issue

I am serving mocha tests that I wish to consume using Electron's loadURL function.

When I attempt to do this using electron-mocha, I get this error:

Error: No test files found: "test"

Assumption

electron-mocha has been designed with the expectation that test files are always available locally.

Setup

Dependencies

...
"electron": "^32.0.1",
"electron-mocha": "^13.0.0"
...

Running

node_modules/.bin/electron-mocha --url=http://localhost:8891 --main=electron-main.js --renderer=true

Any guidance would be greatly appreciated!

@inukshuk
Copy link
Collaborator

Where are your tests at? When you run electron-mocha with the renderer and url options, the window will load your URL and also mocha will run in that window looking for the test files supplied on the command line. You can add the --interactive option which will keep your window open after the tests have run to inspect this further.

@adventurist
Copy link
Author

Where are your tests at? When you run electron-mocha with the renderer and url options, the window will load your URL and also mocha will run in that window looking for the test files supplied on the command line. You can add the --interactive option which will keep your window open after the tests have run to inspect this further.

Thank you, the --interactive is going to be helpful.

As for the tests, they are only available from a remote location. Ultimately they are on a private ip, but for now I'm doing a proof of concept where I'm simply hosting them http://localhost:8891.

If absolutely forced to, I could download them and make the file available for loading as a runtime argument, but I was hoping to simply load via URL, since it's the same data. Is there any way to do that, or must there always be a runtime argument? (the tests are to run in the Renderer)

@inukshuk
Copy link
Collaborator

With --renderer electron-mocha runs mocha in your window, so you need a way to communicate with the the tests you load from the remote location, mocha can't just find them automatically. For example, you could add a test that loads and runs the remote tests: that is, it would probably check that the page has loaded, then run the tests and either fail or succeeded based on the result of the tests. This is one option albeit a silly one: you don't really need a test runner to run a single test which calls another test runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants