Skip to content

switch from karma to web-test-runner #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2022
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
6,986 changes: 4,493 additions & 2,493 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@
"build": "tsc && rollup -c",
"prepublishOnly": "npm run build",
"pretest": "npm run build",
"test": "TZ=Asia/Dubai karma start ./test/karma.config.cjs",
"test": "web-test-runner",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how we were able to bake the timezone feature directly into web-test-runner which allows for different invocations without having to carry environment variables around.

"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'"
},
"prettier": "@github/prettier-config",
"repository": "github/time-elements",
"devDependencies": {
"@github/prettier-config": "0.0.4",
"chai": "^4.3.6",
"chromium": "^3.0.3",
"@open-wc/testing": "^3.1.6",
"@web/dev-server-esbuild": "^0.3.2",
"@web/test-runner": "^0.14.0",
"@web/test-runner-playwright": "^0.8.10",
"eslint": "^8.22.0",
"eslint-plugin-github": "^4.3.7",
"karma": "^6.4.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^10.0.0",
"rollup": "^2.78.1",
"typescript": "^4.7.4"
},
Expand Down
4 changes: 4 additions & 0 deletions test/constructor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {assert} from '@open-wc/testing'
import '../src/local-time-element.ts'
import '../src/relative-time-element.ts'

suite('constructor', function () {
test('create local-time from document.createElement', function () {
const time = document.createElement('local-time')
Expand Down
25 changes: 0 additions & 25 deletions test/karma.config.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions test/local-time.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {assert} from '@open-wc/testing'
import '../src/local-time-element.ts'

suite('local-time', function () {
let fixture
suiteSetup(() => {
Expand Down
3 changes: 3 additions & 0 deletions test/relative-time.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {assert} from '@open-wc/testing'
import '../src/relative-time-element.ts'

suite('relative-time', function () {
test('rewrites from now past datetime to days ago', function () {
const now = new Date(Date.now() - 3 * 60 * 60 * 24 * 1000).toISOString()
Expand Down
3 changes: 3 additions & 0 deletions test/time-ago.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {assert} from '@open-wc/testing'
import '../src/time-ago-element.ts'

suite('time-ago', function () {
let dateNow

Expand Down
3 changes: 3 additions & 0 deletions test/time-until.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {assert} from '@open-wc/testing'
import '../src/time-until-element.ts'

suite('time-until', function () {
test('always uses relative dates', function () {
const now = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000).toISOString()
Expand Down
3 changes: 3 additions & 0 deletions test/title-format.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {assert} from '@open-wc/testing'
import '../src/local-time-element.ts'

suite('title-format', function () {
test('null getFormattedTitle if datetime is missing', function () {
const time = document.createElement('local-time')
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "es2020",
"target": "es2017",
"strict": true,
"moduleResolution": "node",
"declaration": true,
"outDir": "dist",
"lib": ["es2020.intl", "dom", "dom.iterable", "es2020"],
Expand Down
22 changes: 22 additions & 0 deletions web-test-runner.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {esbuildPlugin} from '@web/dev-server-esbuild'
import {playwrightLauncher} from '@web/test-runner-playwright'
const browser = product =>
playwrightLauncher({
product,
createBrowserContext({browser: context}) {
return context.newContext({timezoneId: 'Asia/Dubai'})
}
})

export default {
files: ['test/*'],
nodeResolve: true,
plugins: [esbuildPlugin({ts: true, target: 'es2020'})],
browsers: [browser('chromium')],
testFramework: {
config: {
ui: 'tdd',
timeout: 500
}
}
}