Skip to content

Commit 0a14895

Browse files
authored
test(@tarojs/extend): jest to vitest (#18147)
* test(@tarojs/extend): jest to vitest * test(@tarojs/shared): trigger ci
1 parent bb41575 commit 0a14895

File tree

4 files changed

+33
-54
lines changed

4 files changed

+33
-54
lines changed

packages/taro-extend/jest.config.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/taro-extend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"url": "git+https://github.com/NervJS/taro.git"
1616
},
1717
"scripts": {
18-
"test": "TARO_ENV=weapp jest --coverage false",
19-
"test:dev": "jest --watch",
20-
"test:coverage": "jest --coverage"
18+
"test": "TARO_ENV=weapp vitest run",
19+
"test:dev": "vitest",
20+
"test:coverage": "vitest run --coverage"
2121
},
2222
"bugs": {
2323
"url": "https://github.com/NervJS/taro/issues"

packages/taro-extend/__tests__/selectors.spec.js renamed to packages/taro-extend/tests/index.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { document, options } from '@tarojs/runtime'
2+
import { describe, expect, test } from 'vitest'
23

34
import { Sizzle } from '../src/jquery/sizzle'
45

@@ -13,30 +14,29 @@ describe('selector', () => {
1314
dom.setAttribute('class', 'test')
1415
document.body.appendChild(dom)
1516

16-
it('should work with ID', () => {
17+
test('should work with ID', () => {
1718
const $dom = Sizzle('#test')
1819
expect($dom[0]).toBe(dom)
1920
})
2021

21-
it('should work with tagName', () => {
22+
test('should work with tagName', () => {
2223
const $dom = Sizzle('main')
2324
expect($dom[0]).toBe(dom)
2425
})
2526

26-
it('should work with className', () => {
27+
test('should work with className', () => {
2728
const $dom = Sizzle('.test')
2829
expect($dom[0]).toBe(dom)
2930
})
3031

3132
// TODO: 待修复
32-
it.skip('should work with >', () => {
33+
test.skip('should work with >', () => {
3334
dom.innerHTML = '<view class="t1" id="t1"></view>'
3435
const $dom = Sizzle('main > .t1')
3536
expect($dom[0]).toBe(dom.firstChild)
3637
})
3738

38-
describe('css3', () => {
39-
dom.innerHTML = `
39+
dom.innerHTML = `
4040
<h1 id="header">jQuery Test Suite</h1>
4141
<h2 id="banner"></h2>
4242
<h2 id="userAgent"></h2>
@@ -109,9 +109,9 @@ describe('selector', () => {
109109
<param name="p2" value="x2" />
110110
</object>
111111
112-
<span id="台北Táiběi"></span>
112+
<span id="台北 Táiběi"></span>
113113
<span id="台北" lang="中文"></span>
114-
<span id="utf8class1" class="台北Táiběi 台北"></span>
114+
<span id="utf8class1" class="台北 Táiběi 台北"></span>
115115
<span id="utf8class2" class="台北"></span>
116116
<span id="foo:bar" class="foo:bar"></span>
117117
<span id="test.foo[5]bar" class="test.foo[5]bar"></span>
@@ -236,10 +236,9 @@ describe('selector', () => {
236236
237237
<ol id="tests"></ol>
238238
`
239-
})
240239

241240
function testById (selector, ids) {
242-
it(selector, () => {
241+
test(selector, () => {
243242
const $target = Sizzle(selector)
244243
expect($target.length).toBeGreaterThan(0)
245244
expect($target.map(t => t.id)).toEqual(ids)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
// https://cn.vitest.dev/guide/
4+
export default defineConfig({
5+
define: {
6+
ENABLE_INNER_HTML: true,
7+
ENABLE_ADJACENT_HTML: true,
8+
ENABLE_SIZE_APIS: true,
9+
ENABLE_TEMPLATE_CONTENT: true,
10+
ENABLE_MUTATION_OBSERVER: true,
11+
ENABLE_CLONE_NODE: true,
12+
ENABLE_CONTAINS: true,
13+
},
14+
test: {
15+
include: ['tests/**/*.spec.ts?(x)'],
16+
coverage: {
17+
provider: 'istanbul',
18+
include: ['src/**/*.ts'],
19+
}
20+
}
21+
})

0 commit comments

Comments
 (0)