Skip to content

html file doesnt handle paths correctly #68

Description

@jescalan

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions