test: update unit test
This commit is contained in:
parent
b8f43267ad
commit
e01ba19fce
@ -1,3 +0,0 @@
|
||||
const { fs } = require('memfs')
|
||||
|
||||
module.exports = fs
|
||||
@ -1,3 +0,0 @@
|
||||
const { fs } = require('memfs')
|
||||
|
||||
module.exports = fs.promises
|
||||
@ -8,9 +8,7 @@ import { createPackageJson } from './packageJson.js'
|
||||
import { createRender } from './render.js'
|
||||
import { getTemplate, readFiles, readJsonFile, writeFiles } from './utils/index.js'
|
||||
|
||||
export async function generate(mode: Mode, data: ResolvedData): Promise<void> {
|
||||
const cwd = process.cwd()
|
||||
|
||||
export async function generate(mode: Mode, data: ResolvedData, cwd = process.cwd()): Promise<void> {
|
||||
let userPkg: Record<string, any> = {}
|
||||
if (mode === Mode.init) {
|
||||
const pkgPath = path.join(cwd, 'package.json')
|
||||
|
||||
@ -5,13 +5,14 @@ import { path } from '@vuepress/utils'
|
||||
import { resolveModule } from 'local-pkg'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import { fs, vol } from 'memfs'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { langReplPlugin } from '../src/node/container/langRepl.js'
|
||||
|
||||
vi.mock('node:fs')
|
||||
vi.mock('node:fs/promises')
|
||||
vi.mock('node:fs', () => fs)
|
||||
vi.mock('node:fs/promises', () => fs.promises)
|
||||
|
||||
beforeEach(() => vol.reset())
|
||||
afterEach(() => vol.reset())
|
||||
|
||||
const FENCE = '```'
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ export function createEmbedRuleBlock<Meta extends Record<string, any> = Record<s
|
||||
return false
|
||||
|
||||
// return true as we have matched the syntax
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (silent)
|
||||
return true
|
||||
|
||||
|
||||
@ -2,6 +2,12 @@ import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ['**/__test__/**/*.spec.[tj]s'],
|
||||
exclude: [
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
'**/lib/**',
|
||||
],
|
||||
coverage: {
|
||||
enabled: true,
|
||||
provider: 'istanbul',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user