Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@tool-developer/wx-unit

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tool-developer/wx-unit

wx miniprogram unit test

latest
Source
npmnpm
Version
0.0.6-canary.6
Version published
Maintainers
1
Created
Source

@tool-developer/wx-unit

微信小程序单元测试工具包。

用法

npm install --save-dev @tool-developer/wx-unit

or

yarn add -D @tool-developer/wx-unit
import unit from '@tool-developer/wx-unit'

操作步骤

  • 项目初始化,并配置test scripts
npm init

package.json

"scripts": {
  "test": "jest"
},
  • 安装jest,参考jest.
npm install -g jest
  • 安装依赖和配置babel
npm install -D jest babel-jest babel-core @babel/preset-env @tool-developer/wx-unit

babel.config.js

module.exports = {
  presets: [['@babel/preset-env', {targets: {node: 'current'}}]]
};
  • 创建jest.config.js, 并配置
jest --init

jest.config.js

  "verbose":true,
  "testEnvironment": "node",
  //测试前先启动环境依赖文件
  "setupFiles":['./test.js'],
  //需要编译node_modules时配置
  "transformIgnorePatterns": [
  ],
  //单测覆盖
  "coverageDirectory": "coverage",
  //单测覆盖忽略文件
  "coveragePathIgnorePatterns": [
    "./test.js"
  ],
  //测试路径忽略文件
  "testPathIgnorePatterns": [
    "./test.js"
  ],
  • 在项目目录下创建test.js,这样:
import unit from '@tool-developer/wx-unit';

export default unit;
npm run test

Keywords

wx

FAQs

Package last updated on 02 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts