ember-vitest 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +35 -12
- package/.github/workflows/ci.yml +0 -34
- package/.github/workflows/plan-release.yml +0 -93
- package/.github/workflows/publish.yml +0 -42
- package/.prettierignore +0 -3
- package/.prettierrc.js +0 -3
- package/.release-plan.json +0 -18
- package/CHANGELOG.md +0 -49
- package/RELEASE.md +0 -27
- package/babel.config.js +0 -38
- package/pnpm-workspace.yaml +0 -7
- package/src/create-app.js +0 -17
- package/src/extended-test-context.js +0 -97
- package/src/index.js +0 -7
- package/src/manual.js +0 -79
- package/tests/extended-context/applicationTest-test.gjs +0 -28
- package/tests/extended-context/renderingTest-test.gjs +0 -27
- package/tests/extended-context/test-test.gjs +0 -28
- package/tests/vitest/setupRenderingContext-test.gjs +0 -100
- package/vite.config.js +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-vitest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "integration for testing Ember with Vitest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember",
|
|
@@ -16,10 +16,28 @@
|
|
|
16
16
|
"author": "NullVoxPopuli",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
".":
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./declarations/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./addon-main.js": "./ember-addon-main.cjs",
|
|
24
|
+
"./*": {
|
|
25
|
+
"types": "./declarations/*.d.ts",
|
|
26
|
+
"default": "./dist/*.js"
|
|
27
|
+
}
|
|
20
28
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
"*": [
|
|
32
|
+
"declarations/*"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"ember-addon-main.cjs",
|
|
38
|
+
"dist",
|
|
39
|
+
"declarations"
|
|
40
|
+
],
|
|
23
41
|
"dependencies": {
|
|
24
42
|
"ember-strict-application-resolver": "^0.1.0"
|
|
25
43
|
},
|
|
@@ -27,30 +45,34 @@
|
|
|
27
45
|
"@babel/core": "^7.28.4",
|
|
28
46
|
"@babel/plugin-syntax-explicit-resource-management": "^7.27.1",
|
|
29
47
|
"@babel/plugin-transform-runtime": "^7.28.3",
|
|
48
|
+
"@babel/plugin-transform-typescript": "^7.28.5",
|
|
49
|
+
"@ember/library-tsconfig": "^1.1.3",
|
|
30
50
|
"@ember/test-helpers": "^5.4.0",
|
|
51
|
+
"@embroider/addon-dev": "^8.1.2",
|
|
31
52
|
"@embroider/core": "^4.2.0",
|
|
32
53
|
"@embroider/macros": "^1.18.1",
|
|
33
54
|
"@embroider/vite": "^1.2.0",
|
|
34
55
|
"@glimmer/component": "^2.0.0",
|
|
35
56
|
"@rollup/plugin-babel": "^6.0.4",
|
|
36
57
|
"@testing-library/dom": "^10.4.1",
|
|
37
|
-
"@vitest/browser": "^4.0.
|
|
38
|
-
"@vitest/browser-webdriverio": "^4.0.
|
|
58
|
+
"@vitest/browser": "^4.0.13",
|
|
59
|
+
"@vitest/browser-webdriverio": "^4.0.13",
|
|
39
60
|
"babel-plugin-ember-template-compilation": "^3.0.1",
|
|
40
61
|
"decorator-transforms": "^2.3.0",
|
|
41
62
|
"ember-source": "^6.8.1",
|
|
42
|
-
"explicit-resource-management": "link:@babel/plugin-syntax/explicit-resource-management",
|
|
43
63
|
"prettier": "^3.6.2",
|
|
44
64
|
"prettier-plugin-ember-template-tag": "^2.1.0",
|
|
45
65
|
"release-plan": "^0.17.0",
|
|
66
|
+
"rollup": "^4.53.3",
|
|
46
67
|
"testing-library-ember": "^1.0.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vite": "^7.2.4",
|
|
70
|
+
"vitest": "^4.0.13",
|
|
71
|
+
"webdriverio": "^9.20.1"
|
|
50
72
|
},
|
|
51
73
|
"peerDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
74
|
+
"@ember/test-helpers": ">=4.0.0",
|
|
75
|
+
"vitest": "^4.0.8"
|
|
54
76
|
},
|
|
55
77
|
"engines": {
|
|
56
78
|
"node": "^20.11.0 || ^22 || >=24"
|
|
@@ -61,6 +83,7 @@
|
|
|
61
83
|
"main": "./ember-addon-main.cjs"
|
|
62
84
|
},
|
|
63
85
|
"scripts": {
|
|
86
|
+
"build": "rollup --config",
|
|
64
87
|
"lint": "prettier . --check",
|
|
65
88
|
"lint:fix": "prettier . --write",
|
|
66
89
|
"test": "vitest run --browser.headless",
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
workflow_dispatch:
|
|
4
|
-
pull_request:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
|
|
8
|
-
concurrency:
|
|
9
|
-
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
-
cancel-in-progress: true
|
|
11
|
-
|
|
12
|
-
permissions:
|
|
13
|
-
contents: read
|
|
14
|
-
|
|
15
|
-
##############################################################
|
|
16
|
-
|
|
17
|
-
jobs:
|
|
18
|
-
lints:
|
|
19
|
-
name: "Lints"
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
timeout-minutes: 10
|
|
22
|
-
|
|
23
|
-
steps:
|
|
24
|
-
- uses: wyvox/action@v1
|
|
25
|
-
- run: pnpm lint
|
|
26
|
-
|
|
27
|
-
tests:
|
|
28
|
-
name: "Tests"
|
|
29
|
-
runs-on: ubuntu-latest
|
|
30
|
-
timeout-minutes: 10
|
|
31
|
-
|
|
32
|
-
steps:
|
|
33
|
-
- uses: wyvox/action@v1
|
|
34
|
-
- run: pnpm test || pnpm test
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
name: Plan Release
|
|
2
|
-
on:
|
|
3
|
-
workflow_dispatch:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
- master
|
|
8
|
-
pull_request_target: # This workflow has permissions on the repo, do NOT run code from PRs in this workflow. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
|
|
9
|
-
types:
|
|
10
|
-
- labeled
|
|
11
|
-
- unlabeled
|
|
12
|
-
|
|
13
|
-
concurrency:
|
|
14
|
-
group: plan-release # only the latest one of these should ever be running
|
|
15
|
-
cancel-in-progress: true
|
|
16
|
-
|
|
17
|
-
jobs:
|
|
18
|
-
is-this-a-release:
|
|
19
|
-
name: "Is this a release?"
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
outputs:
|
|
22
|
-
command: ${{ steps.check-release.outputs.command }}
|
|
23
|
-
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
with:
|
|
27
|
-
fetch-depth: 2
|
|
28
|
-
ref: "main"
|
|
29
|
-
# This will only cause the `is-this-a-release` job to have a "command" of `release`
|
|
30
|
-
# when the .release-plan.json file was changed on the last commit.
|
|
31
|
-
- id: check-release
|
|
32
|
-
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
|
|
33
|
-
|
|
34
|
-
create-prepare-release-pr:
|
|
35
|
-
name: Create Prepare Release PR
|
|
36
|
-
runs-on: ubuntu-latest
|
|
37
|
-
timeout-minutes: 5
|
|
38
|
-
needs: is-this-a-release
|
|
39
|
-
permissions:
|
|
40
|
-
contents: write
|
|
41
|
-
issues: read
|
|
42
|
-
pull-requests: write
|
|
43
|
-
# only run on push event or workflow dispatch if plan wasn't updated (don't create a release plan when we're releasing)
|
|
44
|
-
# only run on labeled event if the PR has already been merged
|
|
45
|
-
if: ((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.is-this-a-release.outputs.command != 'release') || (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)
|
|
46
|
-
|
|
47
|
-
steps:
|
|
48
|
-
- uses: actions/checkout@v4
|
|
49
|
-
# We need to download lots of history so that
|
|
50
|
-
# github-changelog can discover what's changed since the last release
|
|
51
|
-
with:
|
|
52
|
-
fetch-depth: 0
|
|
53
|
-
ref: "main"
|
|
54
|
-
- uses: pnpm/action-setup@v4
|
|
55
|
-
- uses: actions/setup-node@v4
|
|
56
|
-
with:
|
|
57
|
-
cache: pnpm
|
|
58
|
-
- run: pnpm install --frozen-lockfile
|
|
59
|
-
- name: "Generate Explanation and Prep Changelogs"
|
|
60
|
-
id: explanation
|
|
61
|
-
run: |
|
|
62
|
-
set +e
|
|
63
|
-
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
|
|
64
|
-
|
|
65
|
-
if [ $? -ne 0 ]; then
|
|
66
|
-
release_plan_output=$(cat release-plan-stderr.txt)
|
|
67
|
-
else
|
|
68
|
-
release_plan_output=$(jq .description .release-plan.json -r)
|
|
69
|
-
rm release-plan-stderr.txt
|
|
70
|
-
|
|
71
|
-
if [ $(jq '.solution | length' .release-plan.json) -eq 1 ]; then
|
|
72
|
-
new_version=$(jq -r '.solution[].newVersion' .release-plan.json)
|
|
73
|
-
echo "new_version=v$new_version" >> $GITHUB_OUTPUT
|
|
74
|
-
fi
|
|
75
|
-
fi
|
|
76
|
-
echo 'text<<EOF' >> $GITHUB_OUTPUT
|
|
77
|
-
echo "$release_plan_output" >> $GITHUB_OUTPUT
|
|
78
|
-
echo 'EOF' >> $GITHUB_OUTPUT
|
|
79
|
-
env:
|
|
80
|
-
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
|
|
81
|
-
|
|
82
|
-
- uses: peter-evans/create-pull-request@v7
|
|
83
|
-
with:
|
|
84
|
-
commit-message: "Prepare Release ${{ steps.explanation.outputs.new_version}} using 'release-plan'"
|
|
85
|
-
labels: "internal"
|
|
86
|
-
branch: release-preview
|
|
87
|
-
title: Prepare Release ${{ steps.explanation.outputs.new_version }}
|
|
88
|
-
body: |
|
|
89
|
-
This PR is a preview of the release that [release-plan](https://github.com/embroider-build/release-plan) has prepared. To release you should just merge this PR 👍
|
|
90
|
-
|
|
91
|
-
-----------------------------------------
|
|
92
|
-
|
|
93
|
-
${{ steps.explanation.outputs.text }}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# For every push to the primary branch with .release-plan.json modified,
|
|
2
|
-
# runs release-plan.
|
|
3
|
-
|
|
4
|
-
name: Publish Stable
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
push:
|
|
9
|
-
branches:
|
|
10
|
-
- main
|
|
11
|
-
- master
|
|
12
|
-
paths:
|
|
13
|
-
- ".release-plan.json"
|
|
14
|
-
|
|
15
|
-
concurrency:
|
|
16
|
-
group: publish-${{ github.head_ref || github.ref }}
|
|
17
|
-
cancel-in-progress: true
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
publish:
|
|
21
|
-
name: "NPM Publish"
|
|
22
|
-
runs-on: ubuntu-latest
|
|
23
|
-
permissions:
|
|
24
|
-
contents: write
|
|
25
|
-
pull-requests: write
|
|
26
|
-
id-token: write
|
|
27
|
-
attestations: write
|
|
28
|
-
|
|
29
|
-
steps:
|
|
30
|
-
- uses: actions/checkout@v4
|
|
31
|
-
- uses: pnpm/action-setup@v4
|
|
32
|
-
- uses: actions/setup-node@v4
|
|
33
|
-
with:
|
|
34
|
-
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
|
|
35
|
-
registry-url: "https://registry.npmjs.org"
|
|
36
|
-
cache: pnpm
|
|
37
|
-
- run: pnpm install --frozen-lockfile
|
|
38
|
-
- name: Publish to NPM
|
|
39
|
-
run: NPM_CONFIG_PROVENANCE=true pnpm release-plan publish
|
|
40
|
-
env:
|
|
41
|
-
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
|
|
42
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierignore
DELETED
package/.prettierrc.js
DELETED
package/.release-plan.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"solution": {
|
|
3
|
-
"ember-vitest": {
|
|
4
|
-
"impact": "patch",
|
|
5
|
-
"oldVersion": "0.2.0",
|
|
6
|
-
"newVersion": "0.2.1",
|
|
7
|
-
"tagName": "latest",
|
|
8
|
-
"constraints": [
|
|
9
|
-
{
|
|
10
|
-
"impact": "patch",
|
|
11
|
-
"reason": "Appears in changelog section :bug: Bug Fix"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"pkgJSONPath": "./package.json"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"description": "## Release (2025-11-13)\n\n* ember-vitest 0.2.1 (patch)\n\n#### :bug: Bug Fix\n* `ember-vitest`\n * [#9](https://github.com/NullVoxPopuli/ember-vitest/pull/9) Add @ember/test-helpers to peerDependencies ([@SergeAstapov](https://github.com/SergeAstapov))\n\n#### Committers: 1\n- Sergey Astapov ([@SergeAstapov](https://github.com/SergeAstapov))\n"
|
|
18
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## Release (2025-11-13)
|
|
4
|
-
|
|
5
|
-
* ember-vitest 0.2.1 (patch)
|
|
6
|
-
|
|
7
|
-
#### :bug: Bug Fix
|
|
8
|
-
* `ember-vitest`
|
|
9
|
-
* [#9](https://github.com/NullVoxPopuli/ember-vitest/pull/9) Add @ember/test-helpers to peerDependencies ([@SergeAstapov](https://github.com/SergeAstapov))
|
|
10
|
-
|
|
11
|
-
#### Committers: 1
|
|
12
|
-
- Sergey Astapov ([@SergeAstapov](https://github.com/SergeAstapov))
|
|
13
|
-
|
|
14
|
-
## Release (2025-11-13)
|
|
15
|
-
|
|
16
|
-
* ember-vitest 0.2.0 (minor)
|
|
17
|
-
|
|
18
|
-
#### :rocket: Enhancement
|
|
19
|
-
* `ember-vitest`
|
|
20
|
-
* [#7](https://github.com/NullVoxPopuli/ember-vitest/pull/7) Upgrade vitest to v4 ([@SergeAstapov](https://github.com/SergeAstapov))
|
|
21
|
-
|
|
22
|
-
#### Committers: 1
|
|
23
|
-
- Sergey Astapov ([@SergeAstapov](https://github.com/SergeAstapov))
|
|
24
|
-
|
|
25
|
-
## Release (2025-10-02)
|
|
26
|
-
|
|
27
|
-
* ember-vitest 0.1.1 (patch)
|
|
28
|
-
|
|
29
|
-
#### :memo: Documentation
|
|
30
|
-
* `ember-vitest`
|
|
31
|
-
* [#5](https://github.com/NullVoxPopuli/ember-vitest/pull/5) Update context setup to `await using`? ([@johanrd](https://github.com/johanrd))
|
|
32
|
-
|
|
33
|
-
#### Committers: 1
|
|
34
|
-
- [@johanrd](https://github.com/johanrd)
|
|
35
|
-
|
|
36
|
-
## Release (2025-09-30)
|
|
37
|
-
|
|
38
|
-
* ember-vitest 0.1.0 (minor)
|
|
39
|
-
|
|
40
|
-
#### :rocket: Enhancement
|
|
41
|
-
* `ember-vitest`
|
|
42
|
-
* [#4](https://github.com/NullVoxPopuli/ember-vitest/pull/4) This looks kinda nice ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
|
|
43
|
-
|
|
44
|
-
#### :house: Internal
|
|
45
|
-
* `ember-vitest`
|
|
46
|
-
* [#1](https://github.com/NullVoxPopuli/ember-vitest/pull/1) Release plan ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
|
|
47
|
-
|
|
48
|
-
#### Committers: 1
|
|
49
|
-
- [@NullVoxPopuli](https://github.com/NullVoxPopuli)
|
package/RELEASE.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Release Process
|
|
2
|
-
|
|
3
|
-
Releases in this repo are mostly automated using [release-plan](https://github.com/embroider-build/release-plan/). Once you label all your PRs correctly (see below) you will have an automatically generated PR that updates your CHANGELOG.md file and a `.release-plan.json` that is used to prepare the release once the PR is merged.
|
|
4
|
-
|
|
5
|
-
## Preparation
|
|
6
|
-
|
|
7
|
-
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
|
|
8
|
-
|
|
9
|
-
- correctly labeling **all** pull requests that have been merged since the last release
|
|
10
|
-
- updating pull request titles so they make sense to our users
|
|
11
|
-
|
|
12
|
-
Some great information on why this is important can be found at [keepachangelog.com](https://keepachangelog.com/en/1.1.0/), but the overall
|
|
13
|
-
guiding principle here is that changelogs are for humans, not machines.
|
|
14
|
-
|
|
15
|
-
When reviewing merged PR's the labels to be used are:
|
|
16
|
-
|
|
17
|
-
- breaking - Used when the PR is considered a breaking change.
|
|
18
|
-
- enhancement - Used when the PR adds a new feature or enhancement.
|
|
19
|
-
- bug - Used when the PR fixes a bug included in a previous release.
|
|
20
|
-
- documentation - Used when the PR adds or updates documentation.
|
|
21
|
-
- internal - Internal changes or things that don't fit in any other category.
|
|
22
|
-
|
|
23
|
-
**Note:** `release-plan` requires that **all** PRs are labeled. If a PR doesn't fit in a category it's fine to label it as `internal`
|
|
24
|
-
|
|
25
|
-
## Release
|
|
26
|
-
|
|
27
|
-
Once the prep work is completed, the actual release is straight forward: you just need to merge the open [Plan Release](https://github.com/NullVoxPopuli/ember-vitest/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR
|
package/babel.config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { buildMacros } from "@embroider/macros/babel";
|
|
2
|
-
|
|
3
|
-
const macros = buildMacros();
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
plugins: [
|
|
7
|
-
["@babel/plugin-syntax-explicit-resource-management"],
|
|
8
|
-
[
|
|
9
|
-
"babel-plugin-ember-template-compilation",
|
|
10
|
-
{
|
|
11
|
-
compilerPath: "ember-source/dist/ember-template-compiler.js",
|
|
12
|
-
enableLegacyModules: [],
|
|
13
|
-
transforms: [...macros.templateMacros],
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
[
|
|
17
|
-
"module:decorator-transforms",
|
|
18
|
-
{
|
|
19
|
-
runtime: {
|
|
20
|
-
import: import.meta.resolve("decorator-transforms/runtime-esm"),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
"@babel/plugin-transform-runtime",
|
|
26
|
-
{
|
|
27
|
-
absoluteRuntime: import.meta.dirname,
|
|
28
|
-
useESModules: true,
|
|
29
|
-
regenerator: false,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
...macros.babelMacros,
|
|
33
|
-
],
|
|
34
|
-
|
|
35
|
-
generatorOpts: {
|
|
36
|
-
compact: false,
|
|
37
|
-
},
|
|
38
|
-
};
|
package/pnpm-workspace.yaml
DELETED
package/src/create-app.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Application from "ember-strict-application-resolver";
|
|
2
|
-
|
|
3
|
-
class App extends Application {
|
|
4
|
-
modules = {};
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function createApp(element) {
|
|
8
|
-
return App.create({ autoboot: false, rootElement: element });
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function create(app, element) {
|
|
12
|
-
if (app) {
|
|
13
|
-
return app.create({ autoboot: false, rootElement: element });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return createApp(element);
|
|
17
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { setApplication, resumeTest, pauseTest } from "@ember/test-helpers";
|
|
2
|
-
|
|
3
|
-
// https://vitest.dev/guide/test-context.html#extend-test-context
|
|
4
|
-
import { test as baseTest } from "vitest";
|
|
5
|
-
import {
|
|
6
|
-
setupContext,
|
|
7
|
-
teardownContext,
|
|
8
|
-
setupRenderingContext,
|
|
9
|
-
setupApplicationContext,
|
|
10
|
-
} from "@ember/test-helpers";
|
|
11
|
-
|
|
12
|
-
import Application from "ember-strict-application-resolver";
|
|
13
|
-
|
|
14
|
-
globalThis.resumeTest = resumeTest;
|
|
15
|
-
|
|
16
|
-
class App extends Application {
|
|
17
|
-
modules = {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const waitForSettled = true;
|
|
21
|
-
const options = { waitForSettled };
|
|
22
|
-
|
|
23
|
-
export const test = baseTest.extend({
|
|
24
|
-
app: ({}, use) => use(App),
|
|
25
|
-
element: ({}, use) => use(document.createElement("div")),
|
|
26
|
-
context: ({}, use) => use({}),
|
|
27
|
-
env: [
|
|
28
|
-
async ({ app, element, context }, use) => {
|
|
29
|
-
document.body.append(element);
|
|
30
|
-
|
|
31
|
-
setApplication(app.create({ autoboot: false, rootElement: element }));
|
|
32
|
-
await setupContext(context, options);
|
|
33
|
-
|
|
34
|
-
await use({
|
|
35
|
-
owner: context.owner,
|
|
36
|
-
element,
|
|
37
|
-
pauseTest,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
await teardownContext(context, options);
|
|
41
|
-
element.remove();
|
|
42
|
-
},
|
|
43
|
-
{ auto: true },
|
|
44
|
-
],
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export const renderingTest = baseTest.extend({
|
|
48
|
-
app: ({}, use) => use(App),
|
|
49
|
-
element: ({}, use) => use(document.createElement("div")),
|
|
50
|
-
context: ({}, use) => use({}),
|
|
51
|
-
env: [
|
|
52
|
-
async ({ app, element, context }, use) => {
|
|
53
|
-
document.body.append(element);
|
|
54
|
-
|
|
55
|
-
setApplication(app.create({ autoboot: false, rootElement: element }));
|
|
56
|
-
await setupContext(context, options);
|
|
57
|
-
await setupRenderingContext(context, options);
|
|
58
|
-
|
|
59
|
-
await use({
|
|
60
|
-
owner: context.owner,
|
|
61
|
-
element,
|
|
62
|
-
pauseTest,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
await teardownContext(context, options);
|
|
66
|
-
element.remove();
|
|
67
|
-
},
|
|
68
|
-
{ auto: true },
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export const applicationTest = baseTest.extend({
|
|
73
|
-
app: ({}, use) => use(App),
|
|
74
|
-
element: ({}, use) => use(document.createElement("div")),
|
|
75
|
-
context: ({}, use) => use({}),
|
|
76
|
-
env: [
|
|
77
|
-
async ({ app, element, context }, use) => {
|
|
78
|
-
document.body.append(element);
|
|
79
|
-
|
|
80
|
-
console.log(app);
|
|
81
|
-
|
|
82
|
-
setApplication(app.create({ autoboot: false, rootElement: element }));
|
|
83
|
-
await setupContext(context, options);
|
|
84
|
-
await setupApplicationContext(context, options);
|
|
85
|
-
|
|
86
|
-
await use({
|
|
87
|
-
owner: context.owner,
|
|
88
|
-
element,
|
|
89
|
-
pauseTest,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
await teardownContext(context, options);
|
|
93
|
-
element.remove();
|
|
94
|
-
},
|
|
95
|
-
{ auto: true },
|
|
96
|
-
],
|
|
97
|
-
});
|
package/src/index.js
DELETED
package/src/manual.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { getOwner } from "@ember/owner";
|
|
2
|
-
import { settled, click } from "@ember/test-helpers";
|
|
3
|
-
import {
|
|
4
|
-
setupContext as emberSetupContext,
|
|
5
|
-
teardownContext,
|
|
6
|
-
setApplication,
|
|
7
|
-
} from "@ember/test-helpers";
|
|
8
|
-
import { renderComponent } from "@ember/renderer";
|
|
9
|
-
import { create as createApp } from "./create-app.js";
|
|
10
|
-
|
|
11
|
-
export function setupContext() {
|
|
12
|
-
let element = document.createElement("div");
|
|
13
|
-
document.body.append(element);
|
|
14
|
-
const app = createApp(element);
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
element,
|
|
18
|
-
get owner() {
|
|
19
|
-
return getOwner(app);
|
|
20
|
-
},
|
|
21
|
-
async [Symbol.asyncDispose]() {
|
|
22
|
-
app.destroy();
|
|
23
|
-
await settled();
|
|
24
|
-
element.remove();
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function setupRenderingContext(app) {
|
|
30
|
-
let element = document.createElement("div");
|
|
31
|
-
document.body.append(element);
|
|
32
|
-
|
|
33
|
-
let renders = [];
|
|
34
|
-
let ctx = {};
|
|
35
|
-
let created = createApp(app, element);
|
|
36
|
-
|
|
37
|
-
setApplication(created);
|
|
38
|
-
|
|
39
|
-
await emberSetupContext(ctx);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
element,
|
|
43
|
-
get owner() {
|
|
44
|
-
return ctx.owner;
|
|
45
|
-
},
|
|
46
|
-
find(selector) {
|
|
47
|
-
return element.querySelector(selector);
|
|
48
|
-
},
|
|
49
|
-
findAll(selector) {
|
|
50
|
-
return element.querySelectorAll(selector);
|
|
51
|
-
},
|
|
52
|
-
click(target) {
|
|
53
|
-
let found = target instanceof Element ? target : this.find(target);
|
|
54
|
-
|
|
55
|
-
return click(found);
|
|
56
|
-
},
|
|
57
|
-
async render(component) {
|
|
58
|
-
let result = await renderComponent(component, {
|
|
59
|
-
into: element,
|
|
60
|
-
owner: ctx.owner,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
renders.push(result);
|
|
64
|
-
await settled();
|
|
65
|
-
},
|
|
66
|
-
async [Symbol.dispose]() {
|
|
67
|
-
renders.forEach((r) => r.destroy());
|
|
68
|
-
teardownContext(ctx);
|
|
69
|
-
element.remove();
|
|
70
|
-
},
|
|
71
|
-
async [Symbol.asyncDispose]() {
|
|
72
|
-
renders.forEach((r) => r.destroy());
|
|
73
|
-
await settled();
|
|
74
|
-
teardownContext(ctx);
|
|
75
|
-
await settled();
|
|
76
|
-
element.remove();
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { applicationTest } from "ember-vitest";
|
|
3
|
-
import { visit, pauseTest } from "@ember/test-helpers";
|
|
4
|
-
|
|
5
|
-
import EmberRouter from "@ember/routing/router";
|
|
6
|
-
import Application from "ember-strict-application-resolver";
|
|
7
|
-
|
|
8
|
-
class Router extends EmberRouter {
|
|
9
|
-
location = "none";
|
|
10
|
-
rootUrl = "/";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class App extends Application {
|
|
14
|
-
modules = {
|
|
15
|
-
"./router": Router,
|
|
16
|
-
"./templates/application": <template>hello there</template>,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("Home", () => {
|
|
21
|
-
applicationTest.scoped({ app: ({}, use) => use(App) });
|
|
22
|
-
|
|
23
|
-
applicationTest("can visit the home screen", async ({ element, env }) => {
|
|
24
|
-
await visit("/");
|
|
25
|
-
|
|
26
|
-
expect(element.textContent).toBe("hello there");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Component from "@glimmer/component";
|
|
2
|
-
import { tracked } from "@glimmer/tracking";
|
|
3
|
-
import { describe, it, expect } from "vitest";
|
|
4
|
-
import { renderingTest } from "ember-vitest";
|
|
5
|
-
import { find, click, render, pauseTest } from "@ember/test-helpers";
|
|
6
|
-
|
|
7
|
-
class Counter extends Component {
|
|
8
|
-
@tracked count = 0;
|
|
9
|
-
increment = () => this.count++;
|
|
10
|
-
|
|
11
|
-
<template>
|
|
12
|
-
<output>{{this.count}}</output>
|
|
13
|
-
<button onclick={{this.increment}}>++</button>
|
|
14
|
-
</template>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe("Counter", () => {
|
|
18
|
-
renderingTest("can interact", async () => {
|
|
19
|
-
await render(<template><Counter /></template>);
|
|
20
|
-
|
|
21
|
-
expect(find("output").textContent).toBe("0");
|
|
22
|
-
|
|
23
|
-
await click("button");
|
|
24
|
-
|
|
25
|
-
expect(find("output").textContent).toBe("1");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { test } from "ember-vitest";
|
|
3
|
-
import Service from "@ember/service";
|
|
4
|
-
import { tracked } from "@glimmer/tracking";
|
|
5
|
-
|
|
6
|
-
class Foo extends Service {
|
|
7
|
-
@tracked count = 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
import Application from "ember-strict-application-resolver";
|
|
11
|
-
|
|
12
|
-
class App extends Application {
|
|
13
|
-
modules = {
|
|
14
|
-
"./services/foo": Foo,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("Container", () => {
|
|
19
|
-
test.scoped({ app: ({}, use) => use(App) });
|
|
20
|
-
|
|
21
|
-
test("works", async ({ context }) => {
|
|
22
|
-
let foo = context.owner.lookup("service:foo");
|
|
23
|
-
|
|
24
|
-
expect(foo.count).toBe(0);
|
|
25
|
-
foo.count++;
|
|
26
|
-
expect(foo.count).toBe(1);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { trackedObject } from "@ember/reactive/collections";
|
|
2
|
-
import { describe, test, expect as hardExpect } from "vitest";
|
|
3
|
-
import { screen } from "@testing-library/dom";
|
|
4
|
-
import { fireEvent } from "testing-library-ember";
|
|
5
|
-
import Service, { service } from "@ember/service";
|
|
6
|
-
import { tracked } from "@glimmer/tracking";
|
|
7
|
-
import Component from "@glimmer/component";
|
|
8
|
-
import Router from "@ember/routing/router";
|
|
9
|
-
import Application from "ember-strict-application-resolver";
|
|
10
|
-
|
|
11
|
-
import { setupRenderingContext } from "ember-vitest";
|
|
12
|
-
|
|
13
|
-
const expect = hardExpect.soft;
|
|
14
|
-
|
|
15
|
-
describe("setupRenderingContext", () => {
|
|
16
|
-
test("it works", async () => {
|
|
17
|
-
using ctx = await setupRenderingContext();
|
|
18
|
-
|
|
19
|
-
await ctx.render(<template>hello there</template>);
|
|
20
|
-
|
|
21
|
-
expect(ctx.element.textContent).contains("hello there");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("has interactivity", async () => {
|
|
25
|
-
using ctx = await setupRenderingContext();
|
|
26
|
-
|
|
27
|
-
const state = trackedObject({ value: 0 });
|
|
28
|
-
const increment = () => state.value++;
|
|
29
|
-
|
|
30
|
-
await ctx.render(
|
|
31
|
-
<template>
|
|
32
|
-
<button onclick={{increment}}>click me</button>
|
|
33
|
-
<output>{{state.value}}</output>
|
|
34
|
-
</template>,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
let btn = screen.getByText(/click me/);
|
|
38
|
-
let out = ctx.element.querySelector("output");
|
|
39
|
-
|
|
40
|
-
expect(btn).toBeTruthy();
|
|
41
|
-
expect(out.textContent).toBe("0");
|
|
42
|
-
|
|
43
|
-
await fireEvent.click(btn);
|
|
44
|
-
expect(out.textContent).toBe("1");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("can access services in the test", async () => {
|
|
48
|
-
class DemoService extends Service {
|
|
49
|
-
@tracked count = 0;
|
|
50
|
-
increment = () => this.count;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
class App extends Application {
|
|
54
|
-
modules = {
|
|
55
|
-
"./services/demo": DemoService,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
using ctx = await setupRenderingContext(App);
|
|
60
|
-
|
|
61
|
-
let demo = ctx.owner.lookup("service:demo");
|
|
62
|
-
|
|
63
|
-
expect(demo.count).toBe(0);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("can access services in a component", async () => {
|
|
67
|
-
class DemoService extends Service {
|
|
68
|
-
@tracked count = 0;
|
|
69
|
-
increment = () => this.count++;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class App extends Application {
|
|
73
|
-
modules = {
|
|
74
|
-
"./services/demo": DemoService,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
using ctx = await setupRenderingContext(App);
|
|
79
|
-
|
|
80
|
-
class Demo extends Component {
|
|
81
|
-
@service demo;
|
|
82
|
-
|
|
83
|
-
<template>
|
|
84
|
-
<button onclick={{this.demo.increment}}>click me</button>
|
|
85
|
-
<output>{{this.demo.count}}</output>
|
|
86
|
-
</template>
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
await ctx.render(<template><Demo /></template>);
|
|
90
|
-
|
|
91
|
-
let btn = ctx.find("button");
|
|
92
|
-
let out = ctx.find("output");
|
|
93
|
-
|
|
94
|
-
expect(btn).toBeTruthy();
|
|
95
|
-
expect(out.textContent).toBe("0");
|
|
96
|
-
|
|
97
|
-
await ctx.click(btn);
|
|
98
|
-
expect(out.textContent).toBe("1");
|
|
99
|
-
});
|
|
100
|
-
});
|
package/vite.config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { webdriverio } from "@vitest/browser-webdriverio";
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
|
|
4
|
-
import { ember, extensions } from "@embroider/vite";
|
|
5
|
-
import { babel } from "@rollup/plugin-babel";
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
test: {
|
|
9
|
-
include: ["tests/**/*-test.{gjs,gts}"],
|
|
10
|
-
maxConcurrency: 1,
|
|
11
|
-
browser: {
|
|
12
|
-
enabled: true,
|
|
13
|
-
provider: webdriverio(),
|
|
14
|
-
// at least one instance is required
|
|
15
|
-
instances: [
|
|
16
|
-
{ browser: "chrome" },
|
|
17
|
-
// { browser: 'firefox' },
|
|
18
|
-
// { browser: 'edge' },
|
|
19
|
-
// { browser: 'safari' },
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
optimizeDeps: {
|
|
24
|
-
include: [
|
|
25
|
-
"@glimmer/component",
|
|
26
|
-
"@ember/test-helpers",
|
|
27
|
-
"ember-strict-application-resolver",
|
|
28
|
-
"ember-source/@ember/component/index.js",
|
|
29
|
-
"ember-source/@ember/service/index.js",
|
|
30
|
-
"ember-source/@ember/template-factory/index.js",
|
|
31
|
-
"ember-source/@ember/component/template-only.js",
|
|
32
|
-
"ember-source/@glimmer/tracking/index.js",
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
plugins: [
|
|
36
|
-
ember(),
|
|
37
|
-
babel({
|
|
38
|
-
babelHelpers: "runtime",
|
|
39
|
-
extensions,
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
});
|