Skip to content

Commit 7f5ad9a

Browse files
authored
Merge branch 'main' into fix-test-extend-type
2 parents 2efa152 + 5d07bba commit 7f5ad9a

File tree

11 files changed

+24
-109
lines changed

11 files changed

+24
-109
lines changed

docs/.vitepress/components.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export {}
77
/* prettier-ignore */
88
declare module 'vue' {
99
export interface GlobalComponents {
10-
AsideViteConf: typeof import('./components/AsideViteConf.vue')['default']
1110
Contributors: typeof import('./components/Contributors.vue')['default']
1211
CourseLink: typeof import('./components/CourseLink.vue')['default']
1312
FeaturesList: typeof import('./components/FeaturesList.vue')['default']

docs/.vitepress/components/AsideViteConf.vue

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

docs/.vitepress/theme/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
99
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
1010
import HomePage from '../components/HomePage.vue'
1111
import Version from '../components/Version.vue'
12-
import AsideViteConf from '../components/AsideViteConf.vue'
1312
import '@shikijs/vitepress-twoslash/style.css'
1413

1514
if (inBrowser) {
@@ -21,7 +20,6 @@ export default {
2120
Layout() {
2221
return h(DefaultTheme.Layout, null, {
2322
'home-features-after': () => h(HomePage),
24-
'aside-ads-before': () => h(AsideViteConf),
2523
})
2624
},
2725
enhanceApp({ app }) {

docs/public/viteconf.svg

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

packages/expect/src/jest-expect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
643643
|| typeof expected === 'undefined'
644644
|| expected instanceof RegExp
645645
) {
646-
return this.throws(expected)
646+
// Fixes the issue related to `chai` <https://github.com/vitest-dev/vitest/issues/6618>
647+
return this.throws(expected === '' ? /^$/ : expected)
647648
}
648649

649650
const obj = this._obj

packages/vitest/src/integrations/css/css-modules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { createHash } from 'node:crypto'
1+
import { hash } from '../../node/hash'
22
import type { CSSModuleScopeStrategy } from '../../node/types/config'
33

44
export function generateCssFilenameHash(filepath: string) {
5-
return createHash('md5').update(filepath).digest('hex').slice(0, 6)
5+
return hash('md5', filepath, 'hex').slice(0, 6)
66
}
77

88
export function generateScopedClassName(

packages/vitest/src/node/cache/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import crypto from 'node:crypto'
21
import { resolve } from 'pathe'
32
import { slash } from '../../utils'
3+
import { hash } from '../hash'
44
import { FilesStatsCache } from './files'
55
import { ResultsCache } from './results'
66

@@ -26,7 +26,7 @@ export class VitestCache {
2626
? resolve(
2727
root,
2828
baseDir,
29-
crypto.createHash('md5').update(projectName, 'utf-8').digest('hex'),
29+
hash('md5', projectName, 'hex'),
3030
)
3131
: resolve(root, baseDir)
3232
}

packages/vitest/src/node/hash.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import crypto from 'node:crypto'
2+
3+
export const hash = crypto.hash ?? ((
4+
algorithm: string,
5+
data: crypto.BinaryLike,
6+
outputEncoding: crypto.BinaryToTextEncoding,
7+
) => crypto.createHash(algorithm).update(data).digest(outputEncoding))

packages/vitest/src/node/pools/rpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createHash } from 'node:crypto'
21
import { mkdir, writeFile } from 'node:fs/promises'
32
import type { RawSourceMap } from 'vite-node'
43
import { join } from 'pathe'
54
import type { WorkspaceProject } from '../workspace'
65
import type { RuntimeRPC } from '../../types/rpc'
6+
import { hash } from '../hash'
77

88
const created = new Set()
99
const promises = new Map<string, Promise<void>>()
@@ -47,7 +47,7 @@ export function createMethodsRPC(project: WorkspaceProject, options: MethodsOpti
4747
}
4848

4949
const dir = join(project.tmpDir, transformMode)
50-
const name = createHash('sha1').update(id).digest('hex')
50+
const name = hash('sha1', id, 'hex')
5151
const tmp = join(dir, name)
5252
if (promises.has(tmp)) {
5353
await promises.get(tmp)

packages/vitest/src/node/sequencers/BaseSequencer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createHash } from 'node:crypto'
21
import { relative, resolve } from 'pathe'
32
import { slash } from 'vite-node/utils'
3+
import { hash } from '../hash'
44
import type { Vitest } from '../core'
55
import type { WorkspaceSpec } from '../pool'
66
import type { TestSequencer } from './types'
@@ -25,7 +25,7 @@ export class BaseSequencer implements TestSequencer {
2525
const specPath = fullPath?.slice(config.root.length)
2626
return {
2727
spec,
28-
hash: createHash('sha1').update(specPath).digest('hex'),
28+
hash: hash('sha1', specPath, 'hex'),
2929
}
3030
})
3131
.sort((a, b) => (a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0))

0 commit comments

Comments
 (0)