I need a way to run my Halogen (PureScript) based web UI offline at compile-time, in order to generate "screenshots" (DOM captures) and run test suites.
Here's my initial attempt.
Build the docker image
Make a directory and put Dockerfile
in it, then run this command in there:
docker image build . -t jsdom
Run jsdom
In the same directory as jsdom.js
, run this:
docker run --net=host --rm -v`pwd`:`pwd` -w`pwd` jsdom node jsdom.js
Output
Here's what my output looked like:
<div class="cell-wrapper" style=""><div class="cell"><div class="cell-header"><div class="cell-name" title="Click to edit cell's name">(unnamed)</div><button class="delete-cell" title="Delete this cell">×</button></div><div class="cell-body"><div class="editor-boundary-wrap clickable-to-edit" title="Click to edit"><div class="misc">123</div></div></div></div></div>
Read this as:
- Blank line because the canvas is empty, and we're querying the server for the initial canvas contents.
- Finally, the last line of HTML output is a snapshot of the current DOM, which includes the part I want:
<div class="cell-wrapper" style="">
<div class="cell">
<div class="cell-header">
<div class="cell-name" title="Click to edit cell's name">(unnamed)</div>
<button class="delete-cell" title="Delete this cell">×</button>
</div>
<div class="cell-body">
<div class="editor-boundary-wrap clickable-to-edit"
title="Click to edit">
<div class="misc">123</div>
</div>
</div>
</div>
</div>