Skip to content

Commit b57c5b0

Browse files
zhawkinsZack Hawkinsgithub-actions[bot]castastrophe
authored
feat: add Web Test Runner framework and tooling (#1538)
* Web Test Runner POC * Removes old test files and adds new test * Updates generator for new tests * Adds new test script and generator for new tests * Adds new tooling to run tests * Updates docs and wtr scripts. * Updates readme to show test generator * Fixes test script for pfe-select element * Updates wtr glob so it doesn't select node_modules tests * Adds caching for ms-playright * Resolves merge conflicts * Updates old react and vue tests to use a CDN instead of local libraries * chore: Update builds to run in parallel; fix watch error (#1535) * chore: Update builds to run in parallel; fix watch error * chore: Add async support for watch tasks Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs: migrate 11ty config to the root of the project (#1542) * chore: Update builds to run in parallel; fix watch error * chore: Add async support for watch tasks * docs: Resolve storybook error; migrate 11ty templates * docs: Abstracting header and footer * docs: Working through rendering issue * docs: Remove build script * docs: Update mkdir logic * docs: Clean up templates * docs: Update templates for imports * docs: Updating the config * docs: Remove doc-listing-inject for now * docs: Update doc listing logic * docs: Add a way to render the TODOS are JSON * docs: Apply design suggestions from Dan * docs: Updating READMEs * docs: Updating CDN references * docs: Update package and remove spandx config * docs: Adjusting the watch script * docs: Update build script * docs: Adjust how packages are brought in so they are loaded in the head * docs: Temporarily remove packages * docs: Run build before storybook and docs * docs: Update build flow * docs: Change mkdir logic * docs: Update script for build * docs: Maintain link to demo pages in footer of production * docs: Fix parallelization in watch task * docs: Update README Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fixes typo * Updates per code review * Updates the test echo now that we support single element watching * Updates pfe-select test command to match the generator * Adds changelong * Changelog update Co-authored-by: Zack Hawkins <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: [ Cassondra ] <[email protected]>
1 parent 9d8d628 commit b57c5b0

File tree

133 files changed

+3929
-2072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+3929
-2072
lines changed

.github/workflows/tests.yml

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
runs-on: ubuntu-latest
5151
strategy:
5252
matrix:
53-
node: [10]
53+
node: ['12.x']
5454
# Confirm that the PR is not in draft
5555
if: |
5656
(
@@ -90,6 +90,7 @@ jobs:
9090
path: |
9191
~/.npm
9292
**/node_modules
93+
~/.cache/ms-playwright
9394
key: ${{ steps.hash.outputs.HASH }}
9495

9596
- name: Install dependencies
@@ -108,15 +109,12 @@ jobs:
108109
path: elements/*/dist/*
109110
if-no-files-found: error
110111

111-
# Test command can run concurrent with e2e so it downloads the
112+
# Test command can run concurrent with e2e and test-wtr so it downloads the
112113
# compiled assets from the build and uses those instead of reinstalling.
113114
test:
114-
name: Run test suite (wct)
115+
name: Run test suite (Web Component Tester)
115116
needs: build
116117
runs-on: ubuntu-latest
117-
strategy:
118-
matrix:
119-
node: [10]
120118
steps:
121119
- name: Checkout repository
122120
uses: actions/checkout@v2
@@ -156,6 +154,57 @@ jobs:
156154
- name: Run tests
157155
run: npm test -- --nobuild
158156

157+
# Test command can run concurrent with e2e and wct so it downloads the
158+
# compiled assets from the build and uses those instead of reinstalling.
159+
test-wtr:
160+
name: Run test suite (Web Test Runner)
161+
needs: build
162+
runs-on: ubuntu-latest
163+
164+
steps:
165+
- name: Checkout repository
166+
uses: actions/checkout@v2
167+
168+
# Configures the node version used on GitHub-hosted runners.
169+
- name: Configure node version
170+
uses: actions/setup-node@v1
171+
with:
172+
node-version: ${{ matrix.node }}
173+
174+
# Set up cross-browser testing on Chromium, WebKit and Firefox with Playwright.
175+
- name: Set up Playwright
176+
uses: microsoft/playwright-github-action@v1
177+
178+
# Caching speeds up the npm install step.
179+
- name: Access cached node modules
180+
id: get-node-cache
181+
uses: actions/cache@v2
182+
with:
183+
# npm cache files are stored in `~/.npm` on Linux/macOS
184+
path: |
185+
~/.npm
186+
**/node_modules
187+
~/.cache/ms-playwright
188+
key: ${{ needs.build.outputs.CACHE_KEY }}
189+
190+
- name: Install dependencies
191+
if: steps.get-node-cache.outputs.cache-hit != 'true'
192+
run: npm ci
193+
194+
- name: Access compiled assets
195+
uses: actions/download-artifact@v2
196+
id: download-compiled-assets
197+
with:
198+
name: compiled-assets
199+
path: elements
200+
201+
- name: Retry build if it failed
202+
if: failure()
203+
run: npm run build
204+
205+
- name: Run tests
206+
run: npm run test:ci
207+
159208
# E2E command can run concurrent with test so it downloads the
160209
# compiled assets from the build and uses those instead of reinstalling.
161210
# Only run visual tests if the PR is labeled "ready to merge" or "run e2e"
@@ -168,9 +217,6 @@ jobs:
168217
contains(github.event.pull_request.user.login, 'dependabot') ||
169218
contains(github.event.pull_request.user.login, 'dependabot-preview')
170219
runs-on: ubuntu-latest
171-
strategy:
172-
matrix:
173-
node: [10]
174220
steps:
175221
- name: BrowserStack environment setup
176222
uses: "browserstack/github-actions/setup-env@master"

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v12.16.3
1+
v12.18.2

CHANGELOG-1.x.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# 1.6.1 (2021)
1+
# 1.7.0 (2021)
2+
3+
- [20cb906](https://github.com/patternfly/patternfly-elements/commit/20cb906b5bf3d9340097170d6be7bdacbb4b12a5) fix: Updating PFElement.log (aka this.log) so it logs arrays and objects, instead of converting them to strings
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Adds Web Test Runner which will eventually replace Web Component Tester
25

3-
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Updating PFElement.log (aka this.log) so it logs arrays and objects, instead of converting them to strings
46

57
# 1.6.0 (2021-04-23)
68

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,47 @@ npm run dev [component-name(s)]
6262

6363
### Testing
6464

65+
#### ✨ New tests ([Web Test Runner](https://modern-web.dev/docs/test-runner/overview/))
66+
67+
```shell
68+
# Run all tests in watch mode.
69+
npm run test:watch
70+
71+
# Run a single test in watch mode.
72+
npm run test:watch --element="pfe-select"
73+
# Or multiple:
74+
npm run test:watch --element="{pfe-select,pfe-card}"
75+
76+
# Run all tests using a React wrapper in watch mode.
77+
npm run test:watch --group="with-react"
78+
79+
# Run all tests using a Vue wrapper in watch mode.
80+
npm run test:watch --group="with-vue"
81+
82+
# Build all elements then run all tests in "watch" mode.
83+
npm run test:build:watch
84+
85+
# Build specific elements then run those tests in "watch" mode.
86+
npm run test:build:watch --element="pfe-select"
87+
# Or multiple:
88+
npm run test:build:watch --element="{pfe-select,pfe-card}"
89+
90+
# Run all tests with and without React and Vue wrappers.
91+
# This is run on pull request within CI.
92+
npm run test:ci
93+
```
94+
95+
Generate a new test file for an existing element by using:
96+
97+
```shell
98+
npm run new:test -- [name-of-element]
99+
100+
# Example:
101+
npm run new:test -- pfe-tabs
102+
```
103+
104+
#### 🕸 Legacy tests ([Web Component Tester](https://github.com/Polymer/web-component-tester))
105+
65106
```shell
66107
# Build and run tests on all components
67108
npm run test

docs/docs/develop/testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Lastly, we can run the test command below to see how we did. I've added the `-p`
185185
npm test pfe-cool-element -- -p
186186
```
187187

188-
This command performs a build, starts up web component tester, and provides us a URL that we can copy and paste into the browser. The command line will give you a URL like this:
188+
This command performs a build, starts up web component tester, and provides us a URL that we can copy and paste into the browser. The command line will give you a URL like this:
189189

190190
![npm test command](/images/develop/develop-testing-npm-test.png)
191191

@@ -298,4 +298,4 @@ That's it for testing! Now that we've created our `pfe-cool-element` and all of
298298
<pfe-cta>
299299
<a href="../pull-request">Next up: Open a pull request</a>
300300
</pfe-cta>
301-
:::
301+
:::

elements/pfe-accordion/test/old-test/pfe-accordion_react_test.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
66
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
77
<script src="/components/web-component-tester/browser.js"></script>
8-
<script src="/components/react/umd/react.production.min.js"></script>
9-
<script src="/components/react-dom/umd/react-dom.production.min.js"></script>
10-
<script src="/components/babel-standalone/babel.min.js"></script>
8+
<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
9+
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
10+
<script src="https://unpkg.com/@babel/standalone/babel.min.js" crossorigin></script>
1111
<script type="module" src="../../dist/pfe-accordion.js"></script>
1212
<script type="text/babel">
1313
function TestSuite() {

elements/pfe-accordion/test/old-test/pfe-accordion_vue_test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
66
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
77
<script src="/components/web-component-tester/browser.js"></script>
8-
<script src="/components/vue/dist/vue.min.js"></script>
8+
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js" crossorigin></script>
99
<script type="module" src="../../dist/pfe-accordion.js"></script>
1010
</head>
1111
<body>

elements/pfe-accordion/test/pfe-accordion_react_test.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
77
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
88
<script src="/components/web-component-tester/browser.js"></script>
9-
<script src="/components/react/umd/react.production.min.js"></script>
10-
<script src="/components/react-dom/umd/react-dom.production.min.js"></script>
11-
<script src="/components/babel-standalone/babel.min.js"></script>
9+
<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
10+
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
11+
<script src="https://unpkg.com/@babel/standalone/babel.min.js" crossorigin></script>
1212
<script type="module" src="../dist/pfe-accordion.js"></script>
1313
<script type="text/babel">
1414
function TestSuite() {

elements/pfe-accordion/test/pfe-accordion_vue_test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
77
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
88
<script src="/components/web-component-tester/browser.js"></script>
9-
<script src="/components/vue/dist/vue.min.js"></script>
9+
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js" crossorigin></script>
1010
<script type="module" src="../dist/pfe-accordion.js"></script>
1111
</head>
1212

elements/pfe-autocomplete/test/pfe-autocomplete_vue_test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
77
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
88
<script src="/components/web-component-tester/browser.js"></script>
9-
<script src="/components/vue/dist/vue.min.js"></script>
9+
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js" crossorigin></script>
1010
<script type="module" src="../dist/pfe-autocomplete.js"></script>
1111
</head>
1212

0 commit comments

Comments
 (0)