-
-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): 增加jest单测命令 一键执行所有单测文件 或是执行某一个组件的单测文件
affects: @varlet/cli, @varlet/ui
- Loading branch information
Showing
15 changed files
with
1,766 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { runCLI } from 'jest' | ||
import { resolve } from 'path' | ||
import { CWD, JEST_CONFIG, SRC_DIR } from '../shared/constant' | ||
import logger from '../shared/logger' | ||
|
||
export async function jest(cmd: { component?: string }) { | ||
const rootDir = cmd.component ? resolve(SRC_DIR, cmd.component) : CWD | ||
|
||
const config = { | ||
rootDir, | ||
config: JEST_CONFIG, | ||
} | ||
try { | ||
await runCLI(config as any, [CWD]) | ||
} catch (e) { | ||
logger.error(e.toString()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { JEST_MEDIA_MOCK, JEST_STYLE_MOCK } from '../shared/constant' | ||
|
||
module.exports = { | ||
moduleNameMapper: { | ||
'\\.(css|less|scss)$': JEST_STYLE_MOCK, | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_MEDIA_MOCK, | ||
}, | ||
moduleFileExtensions: ['js'], | ||
transformIgnorePatterns: ['/node_modules/'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,11 @@ | |
"Material", | ||
"UI" | ||
], | ||
"files": [ | ||
"es", | ||
"cjs", | ||
"umd" | ||
], | ||
"author": "haoziqaq <[email protected]>", | ||
"license": "MIT", | ||
"main": "lib/varlet-ui.js", | ||
|
@@ -19,7 +24,8 @@ | |
"build": "varlet-cli build", | ||
"compile": "varlet-cli compile", | ||
"compile:watch": "varlet-cli compile --watch", | ||
"create": "varlet-cli create" | ||
"create": "varlet-cli create", | ||
"jest": "varlet-cli jest" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/haoziqaq/varlet/issues" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const Button = require('../../../cjs/button').default | ||
const { render, fireEvent } = require('@testing-library/vue') | ||
|
||
test('increments value on click', async () => { | ||
const { getByText } = render(Button) | ||
|
||
// getByText returns the first matching node for the provided text, and | ||
// throws an error if no elements match or if more than one match is found. | ||
getByText('Times clicked: 0') | ||
|
||
const button = getByText('increment') | ||
|
||
// Dispatch a native click event to our button element. | ||
await fireEvent.click(button) | ||
await fireEvent.click(button) | ||
|
||
getByText('Times clicked: 2') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
<script> | ||
export default { | ||
name: 'Index', | ||
name: 'Index' | ||
} | ||
</script> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test('test input', async () => { | ||
console.log('hello') | ||
}) |
Oops, something went wrong.