Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use jest #43

Merged
merged 21 commits into from
May 29, 2020
Merged

Use jest #43

merged 21 commits into from
May 29, 2020

Conversation

fkworld
Copy link
Owner

@fkworld fkworld commented May 29, 2020

使用 jest 作为单元测试框架。

如何在 jest 测试环境中添加 cocos creator 的环境?

  1. 将一个空白 creator 项目打包为 web-mobile,从中拷贝 cocos2d-js-min.js 到自己的项目中。
  2. 配置 jest testEnvironment 为 js-dom。默认不需要修改。
  3. 配置 jest setupFilesAfterEnv,配置文件中去 require("./cocos2d-js-min.js")。注意路径。
  4. 依赖包
    • ts-jest
    • jest
    • typescript
    • @types/jest
    • canvas

参考项目中的文件:
jest.config.js
__test__/cocos2d-js-min.js
jest.setup.js

@fkworld fkworld merged commit 9aaff59 into master May 29, 2020
@fkworld fkworld deleted the use-jest branch May 29, 2020 09:43
@fkworld fkworld mentioned this pull request May 29, 2020
3 tasks
@fkworld
Copy link
Owner Author

fkworld commented Jun 24, 2020

使用jest-canvas-mock库代替canvas库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant