One of my most favoritest things about testling is that it produces not only automated test results, but also you can view the tests locally in-browser. For libraries that interact with the DOM, it's great to also be able to visually verify your test cases.
Unfortunately, when you run testling with an html file (which makes it easier to test dom-based javascript), any externally loaded scripts are referenced from the root at which the testling command was run rather than where the file actually is. This means that if your tests are not at the root of your project, which they hardly ever are, you need a different set of paths for your tests to pass and for you to see the tests run locally. For example:
If you have this folder structure:
example-project
˪ package.json
˪ test
˪ index.js
˪ index.html
...and your html file has these contents...
<div class='foo'>wow such test</div>
<script src='index.js'></script>
...assuming that index.js contains your tests, if you were to open test/index.html, you would see your tests run and all would be well. However, if you were to run $ testling at the root of your project, assuming you have the package.json set up correctly, the tests would not run. If you then change the src of the script in your html file to test/index.js however, the tests will run.
Ideally, when testling ran using an html file, it would load any external paths based on the html file's base path rather than the base path that testling was run from 😀
I haven't looked into to testling's code much, but if you are busy and it would be easier for me to submit a PR, if you point me in the right direction I'd be happy to give this a shot!
One of my most favoritest things about testling is that it produces not only automated test results, but also you can view the tests locally in-browser. For libraries that interact with the DOM, it's great to also be able to visually verify your test cases.
Unfortunately, when you run testling with an html file (which makes it easier to test dom-based javascript), any externally loaded scripts are referenced from the root at which the
testlingcommand was run rather than where the file actually is. This means that if your tests are not at the root of your project, which they hardly ever are, you need a different set of paths for your tests to pass and for you to see the tests run locally. For example:If you have this folder structure:
...and your html file has these contents...
...assuming that
index.jscontains your tests, if you were toopen test/index.html, you would see your tests run and all would be well. However, if you were to run$ testlingat the root of your project, assuming you have thepackage.jsonset up correctly, the tests would not run. If you then change thesrcof the script in your html file totest/index.jshowever, the tests will run.Ideally, when testling ran using an html file, it would load any external paths based on the html file's base path rather than the base path that testling was run from 😀
I haven't looked into to testling's code much, but if you are busy and it would be easier for me to submit a PR, if you point me in the right direction I'd be happy to give this a shot!