Package Exports
- @toolkit-js/itest
 - @toolkit-js/itest/lib/index.js
 
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@toolkit-js/itest) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
itest
Unit or Component test tool.
Features
- ✔︎ 基于 Jest 支持单元测试
 - ✔︎ 基于 Vue Testing Library 支持 Vue2 的组件测试
 - ✔︎ 支持 jsx
 - ✔︎ 支持 TypeScript
 
Installation
Install itest via yarn or npm.
$ yarn add @toolkit-js/itest -DUsage
{
  "main": "index.js",
  "scripts": {
    "test": "itest"
  }
}# Run tests
$ yarn testUnit Test Example
// count.js
export function add(input) {
  return input + 1;
}// count.test.js
import { add } from './count';
it('count', () => {
  expect(add(1)).toBe(2);
});Component Test Example
<!-- HelloWorld.vue -->
<template>
  <div>
    <h1>{{ msg }}</h1>
  </div>
</template>
<script>
  export default {
    name: 'HelloWorld',
    props: {
      msg: String,
    },
  };
</script>// HelloWorld.test.js
import { render } from '@testing-library/vue';
import HelloWorld from './HelloWorld.vue';
test('renders props.msg when passed', async () => {
  // The render method returns a collection of utilities to query your component.
  const msg = 'new message';
  const { getByText } = render(HelloWorld, {
    props: {
      msg,
    },
  });
  // 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(msg);
});