Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build & Test
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
main:
if: ${{ !github.event.pull_request.draft }}
name: "Build & Test"
runs-on: ubuntu-latest
timeout-minutes: 5
container:
image: mcr.microsoft.com/playwright:v1.59.1-noble
options: --user 1001:1001 # Run as non-root user for security

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'

- name: Install dependencies
run: pnpm i

- name: Build
run: pnpm run build

- name: Test
run: pnpm run test
env:
CI: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
coverage
coverage/
node_modules/
.idea/
.vscode/
.vs/
dist/
playwright-report/
test-results/
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"test": "playwright test",
"size-report": "node scripts/compare-package-sizes.js"
},
"keywords": [
Expand All @@ -35,6 +36,7 @@
"vue": "^3.4.0"
},
"devDependencies": {
"@playwright/test": "^1.59.1",
"@ramstack/hotkey": "^1.2.1",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^1.0.0",
Expand All @@ -44,6 +46,7 @@
"rollup": "^4.60.1",
"rollup-plugin-bundle-size": "^1.0.3",
"terser": "^5.46.1",
"tslib": "^2.8.1"
"tslib": "^2.8.1",
"vue": "^3.4.0"
}
}
32 changes: 32 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
testDir: "./tests",
fullyParallel: true,
// Fail the build on CI if you accidentally left test.only in the source code.
forbidOnly: !!process.env.CI,
// Retry on CI only
retries: process.env.CI ? 2 : 0,
// Opt out of parallel tests on CI.
workers: process.env.CI ? 2 : undefined,
reporter: [
["html", { open: "never", outputFolder: "playwright-report" }]
],
use: {
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"]
},
},
{
name: "firefox",
use: {
...devices["Desktop Firefox"]
},
}
]
});
45 changes: 41 additions & 4 deletions pnpm-lock.yaml

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

35 changes: 35 additions & 0 deletions tests/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title>
</head>
<body>
<div id="app"></div>

<script src="../../node_modules/vue/dist/vue.global.js"></script>
<script src="../../dist/vue-hotkey.js"></script>
<script>
function mount(options) {
const { template, data = {} } = options;

const app = Vue.createApp({
data() {
return {
...data
};
},
template
});

app.use(window.HotkeyPlugin);
app.mount("#app");
}

window.__hotkeyTest = {
mount,
};
</script>
</body>
</html>
Loading
Loading