Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simon-he95/transform-json-to-vitest
transform-json-to-vitest make json become test
https://github.com/simon-he95/transform-json-to-vitest
transform-json-to-vitest
Last synced: 10 days ago
JSON representation
transform-json-to-vitest make json become test
- Host: GitHub
- URL: https://github.com/simon-he95/transform-json-to-vitest
- Owner: Simon-He95
- Created: 2022-08-02T14:42:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:38:41.000Z (11 months ago)
- Last Synced: 2024-09-16T14:48:42.974Z (about 2 months ago)
- Topics: transform-json-to-vitest
- Language: TypeScript
- Homepage:
- Size: 76.2 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
## transform-json-to-vitest
通过json生成vitest文件## 安装
```bash
npm install -g transform-json-to-vitest
```## 注意
执行命令目录下需要配置vitest.json文件,详见[vitest.json](./vitest.json)文件
```md
# demo
{
"name": "vitest", // 生成test目录下的文件名
"dependency": "import { describe, it, expect, test } from 'vitest'", // 依赖,如果有额外依赖,可以在这里配置
"describe": [ // 生成describe('name',async ()=>{})
{
"name": "hi",
"type": "async", // 控制是否使用async方法
"command": "skip",
"it": [ // it('name', ()=>...)
{
"expression": "const a = 2", // 可在这里申明或调用变量
"name": "should works",
"expect": "a", // a使用的是expression提供的变量, expect(a).toEqual(2)
"to": "toEqual",
"result": "2"
}
],
"test": [
{
"expression": "const a = 2",
"name": "should works",
"expect": "a",
"to": "toEqual",
"result": "2"
}
]
},
{
"name": "hi",
"type": "async",
"it": [
{
"expression": "const a = 2",
"name": "should works",
"expect": "a",
"to": "toEqual",
"result": "2"
},
{
"expression": "const a = 2",
"name": "should works",
"expect": "a",
"to": "toMatchInlineSnapshot",
"result": ""
}
]
}
]
}```
## 命令
全局安装后可直接运行: transformJsonToVitest