@amadeus-it-group/kassette

中文文档
1.7.6发布于 2026/04/16MITTypeScriptCommonJS构建来源已验证近 30 天下载 1.3万

Development server, used mainly for testing, which proxies requests and is able to easily manage local mocks.

原始使用文档
文档目录5 节
  1. Main features
  2. Installation
  3. Installing from a git clone
  4. User documentation
  5. Developing / Contributing

kassette

npm codecov

kassette-logo
kassette is a development server, used mainly for testing, which proxies requests and
is able to easily manage local mocks.

To use it:

  • install with npm install @amadeus-it-group/kassette
  • add this command to your package.json scripts: kassette -c kassette.config.js
  • and create the configuration file kassette.config.js:
/**
 * @return { import("@amadeus-it-group/kassette").ConfigurationSpec }
 */
exports.getConfiguration = () => {
  return {
    port: 4200,
    mocksFolder: './mocks-folder',
    remoteURL: 'http://127.0.0.1:3000',
    mode: 'local_or_download',

    hook: async ({ mock }) => {
      if (!mock.request.pathname.startsWith('/api/')) {
        mock.setMode('remote');
        return;
      }

      mock.setLocalPath([mock.request.pathname.split('/').slice(1), mock.request.method]);
    },
  };
};

Now run your script to launch the proxy!

With this configuration, input requests targeting URLs starting with /api/ will get processed, and local mocks will be used if present, otherwise data will be downloaded from http://127.0.0.1:3000 with a forwarded request, persisted and used for future input requests.

Note that kassette can also be configured to run as a browser proxy, reading the target URL from the request, and intercepting HTTPS communications.

Check Getting started to learn more.

Main features

  • optionally forward requests to a remote backend
  • record backend responses for later use
  • easily computed and set local mock path
  • fill response to client from backend response, downloaded or persisted
  • modify response to client manually
  • can optionally act as the browser proxy
  • generate TLS certificates on the fly to intercept HTTPS communications (as a man-in-the-middle)
  • integrates nicely into your editor and source control: a simple hierarchy of files is generated in a clean way for inspection, edition, diffing, etc.
  • supports the HAR format to record and replay mocks, either in JSON or in YAML
  • supports HTTP/1.x and HTTP/2.0 both in client and server

Installation

This is a Node.js project using npm for dependency management, so ensure you have those two properly installed. Node.js LTS onwards is supported.

With npm, you can install it in two locations:

  • locally inside your project and run it the usual way (using a npm script or accessing the path explicitly node_modules/.bin/kassette)
  • or install it globally and run it using the command kassette (not advised for self-contained projects)

Besides where it is installed, you have at least two ways to install it:

  • from the npm registry: package's name is @amadeus-it-group/kassette
  • from a git clone (see below)

Installing from a git clone

Clone this repository, and run npm link to install it globally on your computer.

If you want to use it globally only, then there is nothing more to do.

If you want to install it locally though, you need to add one more step. You won't be able to use a package.json dependency, but you can install it manually using npm link @amadeus-it-group/kassette from inside your project.

User documentation

It is advised to start with the Getting started article which describes a few practical usage examples, then check the configuration guide and the API guide. The API reference is also available.

Developing / Contributing

See developer guide for details.

版本与发布记录

@amadeus-it-group/kassette 共发布 18 个版本,首次发布于 2020/10/12;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.7.6latest2026/04/166 个月前
1.7.52026/03/038 个月前
1.7.42026/02/208 个月前
1.7.32025/10/151.1 年前
1.7.22025/04/111.6 年前
1.7.12024/11/281.9 年前

关于 @amadeus-it-group/kassette 的常见问题

@amadeus-it-group/kassette 是什么?

Development server, used mainly for testing, which proxies requests and is able to easily manage local mocks.

如何安装 @amadeus-it-group/kassette?

在项目目录运行 npm install @amadeus-it-group/kassette,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 kassette,可以用 npx kassette 直接运行。

@amadeus-it-group/kassette 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amadeus-it-group/kassette 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amadeus-it-group/kassette 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@amadeus-it-group/kassette 可以商用吗?

@amadeus-it-group/kassette 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@amadeus-it-group/kassette 的下载量有多少?

根据 npm 官方下载统计,@amadeus-it-group/kassette 在 2026/10/06 – 2026/11/04 这 30 天内被下载 12,945 次,日均约 432 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amadeus-it-group/kassette 还在维护吗?

最新版本 1.7.6 发布于 2026/04/16(6 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 3 个;首次发布于 2020/10/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。