-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from yintyuan/release-3.6.8-app
feat: taroize包下单元测试的优化,快照文件的上传,package.json中jest指令更换
- Loading branch information
Showing
11 changed files
with
204 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
], | ||
"testPathIgnorePatterns": [ | ||
"node_modules", | ||
"utils" | ||
"/__tests__/utils.ts" | ||
] | ||
}, | ||
"dependencies": { | ||
|
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
82 changes: 82 additions & 0 deletions
82
packages/taroize/__tests__/__snapshots__/script.test.ts.snap
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,82 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`parseScript app.js 1`] = ` | ||
"import \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
const { | ||
default: withWeapp | ||
} = require(\\"@tarojs/with-weapp\\"); | ||
App({ | ||
onLaunch() { | ||
console.log('onLaunch'); | ||
} | ||
}); | ||
@withWeapp(cacheOptions.getOptionsFromCache(), true) | ||
class App extends React.Component { | ||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
export default App;" | ||
`; | ||
|
||
exports[`parseScript getAPP || getCurrentPages 1`] = ` | ||
"import \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
const { | ||
default: withWeapp | ||
} = require(\\"@tarojs/with-weapp\\"); | ||
App({ | ||
onLaunch() { | ||
const appInstance = Taro.getApp(); | ||
console.log('页面栈信息:', Taro.getCurrentPages()); | ||
} | ||
}); | ||
@withWeapp(cacheOptions.getOptionsFromCache(), true) | ||
class App extends React.Component { | ||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
export default App;" | ||
`; | ||
|
||
exports[`parseScript wxml expression 1`] = ` | ||
"import { Block, View } from \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
const { | ||
default: withWeapp | ||
} = require(\\"@tarojs/with-weapp\\"); | ||
App({ | ||
data: { | ||
srt: 'Hello Word!' | ||
} | ||
}); | ||
@withWeapp(cacheOptions.getOptionsFromCache(), true) | ||
class App extends React.Component { | ||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
export default App;" | ||
`; | ||
|
||
exports[`parseScript wxml jsxText 1`] = ` | ||
"import { Block } from \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
const { | ||
default: withWeapp | ||
} = require(\\"@tarojs/with-weapp\\"); | ||
App({}); | ||
@withWeapp(cacheOptions.getOptionsFromCache(), true) | ||
class App extends React.Component { | ||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
export default App;" | ||
`; |
33 changes: 33 additions & 0 deletions
33
packages/taroize/__tests__/__snapshots__/template.test.ts.snap
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,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`template.ts import 正常情况 import src 为绝对路径 1`] = `"<TemplateDemoTmpl></TemplateDemoTmpl>"`; | ||
|
||
exports[`template.ts import 正常情况 import src 为绝对路径 2`] = ` | ||
"import { Block, View } from \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
import withWeapp from \\"@tarojs/with-weapp\\"; | ||
@withWeapp({}) | ||
class TemplateDemoTmpl extends React.Component { | ||
render() { | ||
return <Block><View>模版DEMO</View></Block>; | ||
} | ||
} | ||
export default TemplateDemoTmpl;" | ||
`; | ||
|
||
exports[`template.ts import 正常情况 import 引入template 1`] = `"<View><TemplateDemoTmpl></TemplateDemoTmpl></View>"`; | ||
|
||
exports[`template.ts import 正常情况 import 引入template 2`] = ` | ||
"import { Block, View } from \\"@tarojs/components\\"; | ||
import React from \\"react\\"; | ||
import Taro from \\"@tarojs/taro\\"; | ||
import withWeapp from \\"@tarojs/with-weapp\\"; | ||
@withWeapp({}) | ||
class TemplateDemoTmpl extends React.Component { | ||
render() { | ||
return <Block><View>模版DEMO</View></Block>; | ||
} | ||
} | ||
export default TemplateDemoTmpl;" | ||
`; |
35 changes: 35 additions & 0 deletions
35
packages/taroize/__tests__/__snapshots__/wxml.test.ts.snap
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,35 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`wxml.ts测试 wx:key="index"会转换成key="index" 1`] = ` | ||
"data.map((item, index) => { | ||
return <View key={index}><Text>{item.name}</Text></View>; | ||
})" | ||
`; | ||
|
||
exports[`wxml.ts测试 wxml 中存在 wxs 1`] = ` | ||
Array [ | ||
Object { | ||
"module": "wxs_demo", | ||
"src": "./wxs__wxs_demo", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`wxml.ts测试 wxml 中存在 wxs 2`] = ` | ||
"module.exports = { | ||
data: 'wxs demo' | ||
};" | ||
`; | ||
|
||
exports[`wxml.ts测试 wxml中image的mode=""会转换成mode 1`] = `"<Image className=\\"img\\" src={imgSrc} mode=\\"scaleToFill\\"></Image>"`; | ||
exports[`wxml.ts测试 wxs模块中的var regexp = getRegExp()转换为var regexp = new RegExp() 1`] = ` | ||
Array [ | ||
Object { | ||
"module": "wxs_regexp", | ||
"src": "./wxs__wxs_regexp", | ||
}, | ||
] | ||
`; | ||
exports[`wxml.ts测试 wxs模块中的var regexp = getRegExp()转换为var regexp = new RegExp() 2`] = `"var regexp = new RegExp();"`; |
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,11 @@ | ||
import generate from '@babel/generator' | ||
import * as t from '@babel/types' | ||
|
||
// 最低限度的转义: https://github.com/mathiasbynens/jsesc#minimal | ||
export function generateMinimalEscapeCode (ast: t.File) { | ||
return generate(ast as any, { | ||
jsescOption: { | ||
minimal: true, | ||
}, | ||
}).code | ||
} |
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