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