Skip to content

Commit c29bbf5

Browse files
authored
Merge pull request #196 from github/web-test-runner
Use Modern Webs Test Runner instead of karma
2 parents a8fb3ba + 460f3f1 commit c29bbf5

File tree

8 files changed

+4923
-3614
lines changed

8 files changed

+4923
-3614
lines changed

package-lock.json

Lines changed: 4775 additions & 3508 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,21 @@
2727
"build:docs": "cd docs && JEKYLL_ENV=production bundle exec jekyll build",
2828
"clean": "tsc --build --clean",
2929
"lint": "eslint . --ignore-path .gitignore",
30-
"pretest": "npm run build",
31-
"test": "npm run lint && karma start test/karma.config.cjs",
30+
"pretest": "npm run build && npm run lint",
31+
"test": "web-test-runner test/*.js --node-resolve",
3232
"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'"
3333
},
3434
"prettier": "@github/prettier-config",
3535
"devDependencies": {
3636
"@github/prettier-config": "^0.0.4",
3737
"@lhci/cli": "^0.7.0",
38+
"@open-wc/testing": "^3.1.2",
3839
"@typescript-eslint/eslint-plugin": "^5.16.0",
3940
"@typescript-eslint/parser": "^5.16.0",
40-
"chai": "^4.3.0",
41-
"chai-spies": "^1.0.0",
42-
"chromium": "^3.0.3",
41+
"@web/test-runner": "^0.13.27",
4342
"eslint": "^8.12.0",
4443
"eslint-plugin-github": "^4.3.6",
45-
"karma": "^6.1.1",
46-
"karma-chai": "^0.1.0",
47-
"karma-chai-spies": "^0.1.4",
48-
"karma-chrome-launcher": "^3.1.0",
49-
"karma-mocha": "^2.0.1",
50-
"karma-mocha-reporter": "^2.2.5",
51-
"mocha": "^8.3.0",
44+
"sinon": "^13.0.1",
5245
"tslib": "^2.3.1",
5346
"typescript": "^4.6.3"
5447
}

test/attr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {expect} from '@open-wc/testing'
12
import {initializeAttrs, defineObservedAttributes, attr} from '../lib/attr.js'
23

34
describe('initializeAttrs', () => {

test/auto-shadow-root.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {expect} from '@open-wc/testing'
2+
import {replace, fake} from 'sinon'
13
import {autoShadowRoot} from '../lib/auto-shadow-root.js'
24

35
describe('autoShadowRoot', () => {
@@ -74,15 +76,19 @@ describe('autoShadowRoot', () => {
7476
instance.appendChild(template)
7577

7678
let shadowRoot = null
77-
chai.spy.on(instance, 'attachShadow', (...args) => {
78-
shadowRoot = Element.prototype.attachShadow.apply(instance, args)
79-
return shadowRoot
80-
})
79+
replace(
80+
instance,
81+
'attachShadow',
82+
fake((...args) => {
83+
shadowRoot = Element.prototype.attachShadow.apply(instance, args)
84+
return shadowRoot
85+
})
86+
)
8187

8288
autoShadowRoot(instance)
8389

8490
expect(instance).to.have.property('shadowRoot').equal(null)
85-
expect(instance.attachShadow).to.have.been.called.once.with.exactly({mode: 'closed'})
91+
expect(instance.attachShadow).to.have.been.calledOnceWith({mode: 'closed'})
8692
expect(shadowRoot.textContent).to.equal('Hello World')
8793
})
8894
})

0 commit comments

Comments
 (0)