jest-runner-tsc 项目教程

jest-runner-tsc 项目教程

jest-runner-tsc 🃏A Jest runner for the TypeScript compiler jest-runner-tsc 项目地址: https://gitcode.com/gh_mirrors/je/jest-runner-tsc

1. 项目的目录结构及介绍

jest-runner-tsc/
├── .github/
│   └── workflows/
├── src/
│   ├── index.ts
│   └── ...
├── tests/
│   └── ...
├── .gitignore
├── jest.config.js
├── package.json
├── README.md
└── tsconfig.json
  • .github/workflows/: 包含 GitHub Actions 的工作流配置文件。
  • src/: 项目的源代码目录,包含 TypeScript 文件。
  • tests/: 测试文件目录,包含项目的测试代码。
  • .gitignore: 指定 Git 忽略的文件和目录。
  • jest.config.js: Jest 测试框架的配置文件。
  • package.json: 项目的依赖和脚本配置文件。
  • README.md: 项目的说明文档。
  • tsconfig.json: TypeScript 的配置文件。

2. 项目的启动文件介绍

项目的启动文件位于 src/index.ts。该文件是项目的入口点,负责初始化项目并启动主要功能。

// src/index.ts
import { run } from './runner';

run();
  • run(): 这是一个函数,负责执行项目的主要逻辑。

3. 项目的配置文件介绍

3.1 jest.config.js

Jest 的配置文件,用于配置测试框架的行为。

module.exports = {
  runner: 'jest-runner-tsc',
  displayName: 'tsc',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  testMatch: ['**/*.test.ts'],
  transform: {
    '^.+\\.tsx?$': 'ts-jest',
  },
};
  • runner: 指定使用的 Jest 运行器。
  • displayName: 测试套件的显示名称。
  • moduleFileExtensions: 指定支持的文件扩展名。
  • testMatch: 指定测试文件的匹配模式。
  • transform: 指定如何转换 TypeScript 文件。

3.2 tsconfig.json

TypeScript 的配置文件,用于配置 TypeScript 编译器的行为。

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}
  • compilerOptions: 编译器选项,包括目标 ECMAScript 版本、模块系统等。
  • include: 指定包含的文件或目录。
  • exclude: 指定排除的文件或目录。

3.3 package.json

项目的依赖和脚本配置文件。

{
  "name": "jest-runner-tsc",
  "version": "1.0.0",
  "scripts": {
    "test": "jest",
    "build": "tsc"
  },
  "dependencies": {
    "typescript": "^4.0.0"
  },
  "devDependencies": {
    "jest": "^26.0.0",
    "ts-jest": "^26.0.0"
  }
}
  • scripts: 定义了项目的脚本命令,如 testbuild
  • dependencies: 项目的生产依赖。
  • devDependencies: 项目的开发依赖。

jest-runner-tsc 🃏A Jest runner for the TypeScript compiler jest-runner-tsc 项目地址: https://gitcode.com/gh_mirrors/je/jest-runner-tsc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

温艾琴Wonderful

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值