跳到正文
cccskills
免费在 GitHub 公开

add-package-tests

Add unit tests to a Datagrok package

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md3.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Add Package Tests

Add unit tests to a Datagrok package using the platform's custom test framework.

Usage

/add-package-tests [package-path]

Instructions

When this skill is invoked, help the user set up and write tests for a Datagrok package.

Step 1: Set up test infrastructure

For a new package with tests:

grok create <package-name> --test

For an existing package:

cd <package-name>
grok add tests
npm install

Step 2: Create test files

Create a src/tests/ directory. Each file covers one test category.

import {category, expect, test} from '@datagrok-libraries/utils/src/test';


category('MyCategory', () => {
  test('should do something', async () => {
    expect(actualValue, expectedValue);
  });

  test('should handle edge case', async () => {
    // Test logic
    expect(result, true);
  });
});

Key test framework functions:

  • category(name, fn) - groups related tests
  • test(name, fn, options?) - defines a single test case
  • expect(actual, expected) - assertion that checks equality

Step 3: Register tests in package-test.ts

Import all test files in src/package-test.ts:

import './tests/my-category-tests';
import './tests/another-category-tests';

Step 4: Skip failing tests

Use the skipReason parameter to temporarily skip a test (always provide a reason such as a GitHub issue):

test('flaky test', async () => {
  expect(1, 11);
}, {skipReason: 'public#4256'});

Step 5: Add inline function tests

For simple functions, add test cases directly in the function annotation using the test parameter:

//name: square
//input: int x
//output: int y
//test: square(1) == 1
//test: square(2) == 4
//test: square(3) == 9
export function square(x: number): number {
  return x ** 2;
}

Supported parameter types for //test: annotations: int, double, bool, string, datetime, map. Types like dataframe, column_list, column, file, blob require an additional helper function call.

Step 6: Run tests

# Local testing with datagrok-tools
grok test

# Against a specific server
grok test --host dev

# With visible browser
grok test --gui

# Specific category or test
grok test --category "MyCategory"
grok test --test "should do something"

Tests can also be run from the Datagrok console or Test Manager in the platform UI.

Key points

  • Import category, test, expect from @datagrok-libraries/utils/src/test
  • Always register test files in src/package-test.ts
  • Use skipReason with a GitHub issue (e.g., public#4256) when skipping tests
  • The //test: annotation on functions is for simple input/output validation
  • For real examples, see the Chem package: public/packages/Chem/

Behavior

  1. Check if the package already has test infrastructure (src/package-test.ts, src/tests/)
  2. If not, set up test support using grok add tests
  3. Create test files with category and test blocks for the functionality the user wants to test
  4. Register the test files in src/package-test.ts
  5. Show the user how to run the tests

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Add support for a new curve data format in the Curves package converter system

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

Create info panels that appear in the context panel based on semantic types

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

Add a new single-objective optimization algorithm to the sci-comp library. Use when the user asks to implement a new optimizer (e.g. gradient descent, BFGS, simulated annealing, differential evolution).

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

Answer a "how do I …" question about the platform with a Gherkin scenario on @datagrok-libraries/bdd that is filmed into a how-to video (grok-bdd guide), so the answer is demonstrated, sent as a video plus numbered steps, and kept as a regression test; the same scenarios, filmed in help mode, are the GIFs of the help pages

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

Translate hand-written Playwright specs (or any existing UI tests) into Gherkin features on @datagrok-libraries/bdd, then prove the features test what they claim by backward-matching them against the originals with independent reviewers, and fix the gaps in the core, the library and the features

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

build-app

免费

Create a Datagrok application with routing, views, and data access

中文简介正在准备中。当前显示原文说明。

datagrok-ai/public742026年10月19日 更新

查看 datagrok-ai 的全部技能

报告此技能的问题