Skip to content

Commit 944bd11

Browse files
committed
2 parents 5f97627 + d96ce6b commit 944bd11

27 files changed

+579
-380
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Owner
2+
* @JuneAndGreen

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Github actions workflow name
2+
name: CI
3+
4+
# Triggers the workflow on push or pull request events
5+
on:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
branches: [master]
10+
11+
jobs:
12+
jest_test:
13+
name: miniprogram-simulate test with jest
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: 16
21+
- run: npm install
22+
- run: npm run test
23+
- run: npm run codecov
24+
25+
karma_test:
26+
name: miniprogram-simulate test with karma
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-node@v3
32+
with:
33+
node-version: 16
34+
- run: npm install
35+
- run: npm i puppeteer@latest
36+
- run: npm run karma

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# miniprogram-simulate
22

33
[![](https://img.shields.io/npm/v/miniprogram-simulate.svg?style=flat)](https://www.npmjs.com/package/miniprogram-simulate)
4-
[![](https://img.shields.io/travis/wechat-miniprogram/miniprogram-simulate.svg)](https://github.com/wechat-miniprogram/miniprogram-simulate)
5-
[![](https://img.shields.io/github/license/wechat-miniprogram/miniprogram-simulate.svg)](https://github.com/wechat-miniprogram/miniprogram-simulate)
6-
[![](https://img.shields.io/codecov/c/github/wechat-miniprogram/miniprogram-simulate.svg)](https://github.com/wechat-miniprogram/miniprogram-simulate)
4+
[![](https://github.com/wechat-miniprogram/miniprogram-simulate/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/wechat-miniprogram/miniprogram-simulate/actions/workflows/ci.yml?query=branch%3Amaster+)
5+
[![](https://img.shields.io/github/license/wechat-miniprogram/miniprogram-simulate.svg)](https://github.com/wechat-miniprogram/miniprogram-simulate/blob/master/LICENSE)
6+
[![](https://img.shields.io/codecov/c/github/wechat-miniprogram/miniprogram-simulate.svg)](https://app.codecov.io/gh/wechat-miniprogram/miniprogram-simulate)
77

88
## 介绍
99

build.js

Lines changed: 371 additions & 351 deletions
Large diffs are not rendered by default.

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const id2 = simulate.load('/path/to/component', 'custom-comp', {
8181
| id | String | 可选字段,如果传了此字段,则表明注册为全局组件,其他组件可直接在 template 中使用而无需在 usingComponents 里引入 |
8282
| tagName | String | 可选字段,指定组件对应的 dom 节点的 tagName,默认取 usingComponents 里的定义或组件自身的 id |
8383
| template | String | 组件模板,即组件对应的 wxml 内容 |
84-
| usingComponents | Object | 使用到的自定义组件映射表 |
84+
| usingComponents | Object | 使用到的自定义组件映射表,子孙组件在进行 usingComponents 处理时,会从此表寻找同名组件进行覆盖处理,支持传入覆盖路径或者组件 id |
8585
| behaviors | Array<Behavior> | behavior 的用法和小程序类似 |
8686
| options | Object | 配置对象,支持小程序自定义组件 options 定义段支持的所有字段 |
8787
| options.classPrefix | String | 组件样式的私有化前缀,默认是空串,即没有前缀 |

docs/update.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# 更新日志
22

3+
## 1.5.6
4+
5+
* storage 系列接口支持存取字符串内容
6+
7+
## 1.5.5
8+
9+
* 修复 global.wx 赋值会覆盖用户模拟的 wx 对象问题
10+
11+
## 1.5.3
12+
13+
* 支持子孙组件的 usingComponents 覆盖
14+
315
## 1.5.0
416

517
* load 方法支持 compilerOptions 配置

karma.conf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Karma configuration
22
// Generated on Fri Jan 11 2019 20:11:14 GMT+0800 (CST)
33

4+
process.env.CHROME_BIN = require('puppeteer').executablePath();
45
const path = require('path')
56

67
module.exports = function(config) {
@@ -77,12 +78,12 @@ module.exports = function(config) {
7778

7879
// start these browsers
7980
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
80-
browsers: ['Chrome'],
81+
browsers: ['ChromeHeadless'],
8182

8283

8384
// Continuous Integration mode
8485
// if true, Karma captures browsers, runs the tests and exits
85-
singleRun: false,
86+
singleRun: true,
8687

8788
// Concurrency level
8889
// how many browser should be started simultaneous

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "miniprogram-simulate",
3-
"version": "1.5.2",
3+
"version": "1.5.8",
44
"description": "tools for miniprogram custom component unit test",
55
"main": "index.js",
66
"types": "index.d.ts",
@@ -47,14 +47,14 @@
4747
"eslint-plugin-node": "^7.0.1",
4848
"eslint-plugin-promise": "^3.8.0",
4949
"jest": "^26.0.1",
50-
"karma": "^3.1.4",
50+
"karma": "^6.3.20",
5151
"karma-chai": "^0.1.0",
52-
"karma-chrome-launcher": "^2.2.0",
52+
"karma-chrome-launcher": "^3.1.1",
5353
"karma-dirname-preprocessor": "latest",
5454
"karma-filemap-preprocessor": "latest",
55-
"karma-mocha": "^1.3.0",
56-
"karma-webpack": "^3.0.5",
57-
"mocha": "^5.2.0",
55+
"karma-mocha": "^2.0.1",
56+
"karma-webpack": "^4.0.2",
57+
"mocha": "^10.0.0",
5858
"pretty-format": "^26.0.1",
5959
"webpack": "^4.41.2",
6060
"webpack-cli": "^3.3.10"

src/api/data.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ module.exports = {
2626
_.runInAsync(options, res)
2727
},
2828
getStorageSync(key) {
29-
return JSON.parse(localStorage.getItem(key))
29+
const res = localStorage.getItem(key)
30+
try {
31+
return JSON.parse(res)
32+
} catch (err) {
33+
return res
34+
}
3035
},
3136
getStorageInfo(options) {
3237
let res = {errMsg: 'getStorageInfo:ok'}

0 commit comments

Comments
 (0)