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

--bundle and --consolify don't play well with subfolders #140

Open
jonny-improbable opened this issue Jul 14, 2016 · 3 comments
Open

--bundle and --consolify don't play well with subfolders #140

jonny-improbable opened this issue Jul 14, 2016 · 3 comments

Comments

@jonny-improbable
Copy link

The HTML runner generated using the --consolify flag does not resolve the relative path to the bundle generated by the --bundle flag; instead the absolute value is used.

Steps to repro:

Run mochify over a test suite specifying both a --bundle and --consolify flag whose value points to a subfolder (eg: tmp).

mkdir tmp
mochify --recursive test/ --bundle tmp/tests.js --consolify tmp/runner.html

Expected

  • tmp/tests.js is created
  • tmp/runner.html is created
  • tmp/runner.html resolves the relative path to the javascript bundle and includes it via a script tag (ie: <script src="./tests.js">)

Actual

  • tmp/tests.js is created
  • tmp/runner.html is created
  • tmp/runner.html attempts to load the bundle using the exact value passed to the --bundle flag (ie: <script src="tmp/tests.js>)
jonnyreeves added a commit to jonnyreeves/mochify.js that referenced this issue Jul 14, 2016
jonnyreeves added a commit to jonnyreeves/mochify.js that referenced this issue Jul 14, 2016
jonnyreeves added a commit to jonnyreeves/mochify.js that referenced this issue Jul 15, 2016
Fixes mantoni#140
Add Test Coverage for --bundle and --consolify args

* Fail with a useful error if the user tries to use --bundle wihout --consolify
* Add test-coverage to check that both the consolify'd HTML and extracted bundle are written to disk
@jonnyreeves
Copy link
Contributor

As mentioned in #141, I was unable to solve this in mochify.js directly as consolify is responsible for writing the bundle (and therefore requires the absolute path for its output).

I can think of a couple of ways to solve this, but both will require a change to consolify's API and mochfy.js's invocation of it.

  1. Supply the opts.consolify value to consolify so it knows where the final html document will be written to; it can then use this to resolve the relative path for populating the script tag's src attribute.
  2. Modify consolify so it doesn't write the bundle to disk but instead writes to to a stream supplied by mochify.

Welcome to any other suggestions you have @mantoni?

@mantoni
Copy link
Owner

mantoni commented Jul 15, 2016

@jonnyreeves I think it makes sense to add a -o / --outfile option to consolify. The current behavior could remain as the default. Ideally we can kill the internal wrapper and remove the consolify dependency.

@mantoni
Copy link
Owner

mantoni commented Jun 2, 2017

What is the status here? What is left to do in mochify.js?

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

No branches or pull requests

3 participants