MCPcopy Create free account
hub / github.com/chakra-ui/panda / createEngine

Function createEngine

packages/node/__tests__/output-engine.test.ts:4–34  ·  view source on GitHub ↗
(fs: {
  existsSync: ReturnType<typeof vi.fn>
  readFileSync: ReturnType<typeof vi.fn>
  writeFile: ReturnType<typeof vi.fn>
  ensureDirSync: ReturnType<typeof vi.fn>
})

Source from the content-addressed store, hash-verified

2import { OutputEngine } from '../src/output-engine'
3
4function createEngine(fs: {
5 existsSync: ReturnType<typeof vi.fn>
6 readFileSync: ReturnType<typeof vi.fn>
7 writeFile: ReturnType<typeof vi.fn>
8 ensureDirSync: ReturnType<typeof vi.fn>
9}) {
10 return new OutputEngine({
11 paths: { root: ['styled-system'] },
12 runtime: {
13 fs: {
14 existsSync: fs.existsSync,
15 readFileSync: fs.readFileSync,
16 writeFile: fs.writeFile,
17 ensureDirSync: fs.ensureDirSync,
18 },
19 path: {
20 join: (...parts: string[]) => parts.join('/'),
21 dirname: (p: string) => p.split('/').slice(0, -1).join('/'),
22 resolve: (...parts: string[]) => parts.join('/'),
23 extname: (p: string) => p.slice(p.lastIndexOf('.')),
24 relative: (from: string, to: string) => to.replace(`${from}/`, ''),
25 isAbsolute: (p: string) => p.startsWith('/'),
26 sep: '/',
27 abs: (_cwd: string, p: string) => p,
28 },
29 cwd: () => '/project',
30 env: () => undefined,
31 },
32 hooks: {},
33 } as any)
34}
35
36describe('OutputEngine.write', () => {
37 test('writes when the file does not exist', async () => {

Callers 1

Calls 1

joinMethod · 0.65

Tested by

no test coverage detected