Skip to content

Commit

Permalink
✅ Update moonshiner
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman committed May 14, 2024
1 parent a3898d5 commit 98f52e4
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 123 deletions.
174 changes: 115 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "npm run lint && npm run test:coverage",
"test:coverage": "nyc npm run test:only",
"test:debug": "npm run test:only -- --debug",
"test:only": "NODE_ENV=test node tests/run.js",
"test:only": "NODE_ENV=test npx moonshiner",
"test:types": "tsc --project tests",
"lint": "eslint --ignore-path .gitignore --ignore-pattern www ."
},
Expand All @@ -44,7 +44,7 @@
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"istanbul-lib-coverage": "^3.2.2",
"moonshiner": "^0.15.2",
"moonshiner": "^1.0.0-beta.9",
"nyc": "^15.1.0",
"rollup": "^4.9.6",
"rollup-plugin-glob-import": "^0.5.0",
Expand Down
18 changes: 9 additions & 9 deletions tests/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createTestHook } from 'moonshiner/utils';
import { Interactor } from 'interactor.js';

// Test interactor scoped to the testing fixtures
Expand All @@ -8,20 +7,21 @@ export const I = new Interactor({
});

// Test hook which sets up and tears down HTML fixtures
export const fixture = createTestHook(innerHTML => {
let $test = document.createElement('div');
export const fixture = innerHTML => {
// clean up any existing testing-root
document.getElementById('testing-root')?.remove();

// format HTML to remove extraneous spaces
let ind = innerHTML.match(/^\n(\s*)/)?.[1]?.length;
innerHTML = innerHTML.replace(new RegExp(`^\\s{${ind}}`, 'mg'), '').trim();

// assign HTML and append to the body
Object.assign($test, { id: 'testing-root', innerHTML });
document.body.appendChild($test);

// return a cleanup function
return () => $test.remove();
});
document.body.appendChild(
Object.assign(document.createElement('div'), {
id: 'testing-root',
innerHTML
}));
};

// Test helper to create an event listener spy
export function listen(selector, event, fn) {
Expand Down
8 changes: 1 addition & 7 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import { use, configure, run } from 'moonshiner';
import reporters from 'moonshiner/reporters';

use(reporters.remote());
configure({ timeout: 10_000 });

import('./**/*.test.js').then(run);
import('./**/*.test.js');
Loading

0 comments on commit 98f52e4

Please sign in to comment.