Skip to content

Commit 3471d72

Browse files
authored
feat!: lit 3 update, migrate to vitest with browser mode (#220)
* feat: migrate to vitest + browser mode * chore: update dependencies and minor test cleanup * chore: update vitest * test: refactor tests in date-picker-dialog/* * ci: fix linting that breaks ci * ci: update Playwright command in ci * feat: add @testing-library/jest-dom for DOM assertions * test: fix test to always query newly attached node * test: update tests to use custom jest matchers * test: update tests of InputSurface and clampValue * test: update tests of dateValidator * test: update tests of focusElement * test: refactor tests of isInCurrentMonth * fix: fix .toMatchInlineSnapshot throws uncaught error * test: refactor tests of nullishAttributeConverter * test: refactor tests of splitString * test: refactor tests of toClosestTarget & toDateString * test: refactor tests of toDayDiffInclusive * test: refactor tests of toFormatters * test: refactor tests of toMultiCalendars * test: refactor tests of toNextSelectableDate * test: refactor tests of toNextSelectedDate * test: refactor tests of toResolvedDate * test: refactor tests of toYearList * test: refactor tests of warnUndefinedElement * test: refactor tests of AppIconButton * test: refactor tests of monthCalendar * test: refactor tests of AppYearGrid * test: refactor tests of AppYearGridButton * test: exclude some files that do not need to be coverage collected * test: refactor tests of AppDatePickerInput * test: fix imports in tests that violate ESLint rules * test: fix imports that import node.js modules * chore: update dependencies * ci: remove unused ci-helpers.yml * chore: remove wtr, update README * chore: remove .js extension in test file Signed-off-by: Rong Sen Ng (motss) <[email protected]>
1 parent 90fc29c commit 3471d72

Some content is hidden

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

59 files changed

+8797
-19910
lines changed

.build.eslintrc.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": [
3+
"./.eslintrc.json"
4+
],
5+
"rules": {
6+
"import/named": "off"
7+
}
8+
}

.eslintrc.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"extends": [
33
"./node_modules/@reallyland/tools/browser/lit/.eslintrc.json"
4-
]
4+
],
5+
"rules": {
6+
"import/named": "off",
7+
"import/no-duplicates": "off"
8+
}
59
}

.github/workflows/ci-helpers.yml

-101
This file was deleted.

.github/workflows/ci.yml

+27-12
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ defaults:
1616
shell: bash
1717

1818
env:
19-
COVERAGE: false
19+
FORCE_COLOR: 3
2020
IS_UBUNTU: false
2121
NODE_VERSION: v0.0.0
2222
NPM_CACHE_DIR: ~/.npm
2323
NPM_VERSION: 0.0.0
24+
PNPM_STORE_PATH: .pnpm-store
25+
PNPM_VERSION: 0.0.0
2426

2527
jobs:
2628
test:
@@ -33,17 +35,29 @@ jobs:
3335
strategy:
3436
matrix:
3537
os: [ubuntu-latest]
36-
target: [18.x]
38+
target: [20.x]
3739

3840
steps:
3941
- name: Checkout
4042
uses: actions/checkout@v3
4143

44+
- name: Install pnpm
45+
uses: pnpm/[email protected]
46+
with:
47+
version: latest
48+
49+
- name: Set node version to ${{ matrix.target }}
50+
uses: actions/setup-node@v3
51+
with:
52+
node-version: ${{ matrix.target }}
53+
4254
- name: List versions
4355
run: |
4456
echo "NODE_VERSION=$(node -v)" >> $GITHUB_ENV
4557
echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_ENV
4658
echo "NPM_VERSION=$(npm -v)" >> $GITHUB_ENV
59+
echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
60+
echo "PNPM_VERSION=$(pnpm -v)" >> $GITHUB_ENV
4761
4862
echo "${{ github.workflow }}-${{ github.ref || github.run_id }}"
4963
pwd
@@ -52,41 +66,42 @@ jobs:
5266
# npm x -y -- envinfo@latest
5367
5468
- name: Cache dependencies
55-
id: npm-cache
69+
id: pnpm-cache
5670
uses: actions/cache@v3
5771
with:
5872
# See this glob workaround at https://github.com/actions/toolkit/issues/713.
5973
path: |
6074
${{ env.NPM_CACHE_DIR }}/*
6175
!${{ env.NPM_CACHE_DIR }}/_npx
62-
key: ${{ matrix.os }}-node-${{ env.NODE_VERSION }}-npm-${{ env.NPM_VERSION }}-${{ hashFiles('**/package-lock.json') }}
76+
${{ env.PNPM_STORE_PATH }}
77+
key: ${{ matrix.os }}-node-${{ env.NODE_VERSION }}-pnpm-${{ env.PNPM_VERSION }}-${{ hashFiles('**/pnpm-lock.yaml') }}
6378
restore-keys: |
6479
${{ matrix.os }}-node-${{ env.NODE_VERSION }}-npm-${{ env.NPM_VERSION }}
80+
${{ matrix.os }}-node-${{ env.NODE_VERSION }}-pnpm-${{ env.PNPM_VERSION }}
6581
6682
- name: Install dependencies
6783
run: |
68-
npm ci
69-
sh $(npm root)/@reallyland/tools/list-npx-cache.sh
84+
npm pkg delete scripts.postinstall
85+
pnpm install --frozen-lockfile
86+
# sh $(npm root)/@reallyland/tools/list-npx-cache.sh
7087
7188
- name: Setup Playwright
7289
run: |
73-
npx playwright install-deps
90+
pnpm exec playwright install
7491
7592
- name: Lint
7693
run: |
77-
npm run lint:build
94+
pnpm lint:build
7895
7996
- name: Test
8097
if: env.IS_UBUNTU == 'false'
8198
run: |
82-
npm run wtr
99+
pnpm test:pw --no-coverage
83100
84101
- name: Test with coverage
85102
if: env.IS_UBUNTU != 'false'
86103
run: |
87-
npm run wtr
88-
env:
89-
COVERAGE: true
104+
pnpm test:pw --color
90105
91106
- name: Upload coverage to codecov
92107
if: env.IS_UBUNTU != 'false' && success()

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- [my-app.js](#my-appjs)
3737
- [index.html](#indexhtml)
3838
- [Browser compatibility](#browser-compatibility)
39-
- [Q&A](#qa)
39+
- [Q\&A](#qa)
4040
- [API references](#api-references)
4141
- [Demo](#demo)
4242
- [Older versions](#older-versions)
@@ -67,17 +67,17 @@ The following are the list of tools used that makes it shine:
6767
- [my-app.js](#my-appjs)
6868
- [index.html](#indexhtml)
6969
- [Browser compatibility](#browser-compatibility)
70-
- [Q&A](#qa)
70+
- [Q\&A](#qa)
7171
- [API references](#api-references)
7272
- [Demo](#demo)
7373
- [Older versions](#older-versions)
7474
- [License](#license)
7575

7676
## Pre-requisite
7777

78-
- [ES2019] _(The element is compiled with features targeting ES2019, so it might not work properly without transpilation on older browsers.)_
79-
- [lit] >= 2.2.0
80-
- [OPTIONAL] [TypeScript] >= 4.5.5 _(TypeScript users only)_
78+
- [ES2021] _(The element is compiled with features targeting ES2021, so it might not work properly without transpilation on older browsers.)_
79+
- [lit] >= 3.1.0
80+
- [TypeScript] >= 5.3.3 _(Note: TypeScript users only)_
8181

8282
## Installation
8383

@@ -242,7 +242,7 @@ Not tested on the following browsers but it should work with all the polyfills n
242242
[AppDatePickerInput]: /docs/app-date-picker-input.md
243243
[Array.prototype.find]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
244244
[awesome-lit-html]: https://github.com/web-padawan/awesome-lit-html#individual-components
245-
[ES2019]: https://kangax.github.io/compat-table/es2016plus/#test-Object.fromEntries
245+
[ES2021]: https://compat-table.github.io/compat-table/es2016plus
246246
[esm-sh-url]: https://esm.sh/app-datepicker@next?target=es2019
247247
[Intl.DateTimeFormat]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
248248
[jsdelivr-url]: https://www.jsdelivr.com/package/npm/app-datepicker?version=next&amp;utm_source=github.com&amp;utm_medium=referral&amp;utm_content=motss/app-datepicker

0 commit comments

Comments
 (0)