Skip to content

Commit

Permalink
get something working with testing experimental moveBefore.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed Dec 13, 2024
1 parent e636206 commit b7d330c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ jobs:
- name: Run tests
run: npm run ci

test-move-before:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test-move-before

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
/coverage
/test/chrome-profile
.idea
6 changes: 6 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ npm run ci
```
This will run the tests using Playwright’s headless browser setup across Chrome, Firefox, and WebKit (Safari-adjacent). This is ultimately what gets run in Github Actions to verify PRs.

To run all tests against Chrome with experimental `moveBefore` support added, execute:
```bash
npm run test-move-before
```
This will start headless Chrome in a new profile with the `atomic-move` experimental flag set. This runs in a separate job in CI.

## Running Individual Tests

### Headless Mode
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"scripts": {
"test": "web-test-runner",
"debug": "web-test-runner --manual --open",
"test-move-before": "USE_MOVE_BEFORE=1 web-test-runner",
"ci": "web-test-runner --playwright --browsers chromium firefox webkit",
"amd": "(echo \"define(() => {\n\" && cat src/idiomorph.js && echo \"\nreturn Idiomorph});\") > dist/idiomorph.amd.js",
"cjs": "(cat src/idiomorph.js && echo \"\nmodule.exports = Idiomorph;\") > dist/idiomorph.cjs.js",
Expand Down
4 changes: 2 additions & 2 deletions src/idiomorph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,9 +1101,9 @@ var Idiomorph = (function () {
// @ts-ignore - use proposed moveBefore feature
if (ctx.pantry.moveBefore) {
// @ts-ignore - use proposed moveBefore feature
ctx.pantry.moveBefore(node)
ctx.pantry.moveBefore(node);
} else {
ctx.pantry.appendChild(node);
ctx.pantry.insertBefore(node, null);
}
}

Expand Down
25 changes: 21 additions & 4 deletions web-test-runner.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
nodeResolve: true,
coverage: true,
files: "test/*.js",
import { chromeLauncher } from "@web/test-runner";
import { exec } from "child_process";

let config = {
testRunnerHtml: (testFramework) => `
<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -29,5 +29,22 @@ export default {
</body>
</html>
`,

nodeResolve: true,
coverage: true,
files: "test/*.js",
};

if (process.env.USE_MOVE_BEFORE) {
// configure chrome to use a custom profile directory we control
config.browsers = [
chromeLauncher({ launchOptions: { args: ['--user-data-dir=test/chrome-profile'] } })
]
exec([
'rm -rf test/chrome-profile', // clear profile out from last run
'mkdir -p test/chrome-profile', // create from scratch
`echo '{"browser":{"enabled_labs_experiments":["atomic-move@1"]}}' > test/chrome-profile/Local\\ State`, // enable experiment
].join(" && "));
}

export default config;

0 comments on commit b7d330c

Please sign in to comment.