Skills Plugins MCP Prompt Model 博客 我的中心
开发编程 #typescript #browser #ai

node-native-tests

Write and maintain TypeScript tests for Node.js-only modules using only the native node:test runner and node:assert/strict, with no browser, DOM, Jest, Vitest, or transpiler-based test runner.

DeepseekModel 官方收录技能 质量 良好 · 48 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=dkolba-bruff-agents-skills-node-native-tests-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name node-native-tests description Write and maintain TypeScript tests for Node.js-only modules using only the native node:test runner and node:assert/strict, with no browser, DOM, Jest, Vitest, or transpiler-based test runner. Node Native Tests Use this skill when writing tests for Node.js modules where the test stack must be: TypeScript source files executed directly by Node.js node:test for test definitions, lifecycle hooks, subtests, mocking, and timers node:assert/strict for assertions no browser APIs, DOM APIs, Jest, Vitest, Playwright, jsdom, tsx, ts-node, or Babel Workflow Confirm the target is a Node.js module, not browser or DOM code. Read the module API and existing package scripts before choosing file names or commands. Add colocated *.test.ts files unless the package already has a dedicated Node test directory. Write the failing test first, using only public exports. Run the smallest native command that covers the new test. Run type checking separately; Node executes TypeScript but does not type-check it. Native TypeScript Constraints Node.js runs TypeScript through type stripping. Keep tests and imported test-only helpers inside erasable TypeScript syntax: Use .ts , do not use .mts , .cts or .tsx . Include real file extensions in relative imports: ./parser.ts , not ./parser . Use import type for type-only imports. Avoid syntax that requires transformation: enum , parameter properties, runtime namespaces, decorators, and TypeScript path aliases. Do not assume tsconfig.json changes Node runtime behavior. tsconfig.json is for editors and tsc . Recommended tsconfig.json options for native Node TypeScript projects: { "compilerOptions" : { "noEmit" : true , "target" : "esnext" , "module" : "nodenext" , "rewriteRelativeImportExtensions" : true , "erasableSyntaxOnly" : true , "verbatimModuleSyntax" : true } } If the project imports .ts extensions and type-checks without emitting, also ensure the compiler accepts those imports, for example with allowImportingTsExtensions where appropriate. Running Tests Prefer explicit globs for TypeScript tests: node -- test "**/*.test.ts" For Node versions earlier than v22.18.0 , TypeScript execution may require: node --experimental-strip-types -- test "**/*.test.ts" Type-check separately: tsc --noEmit Useful native runner flags: --test-name-pattern "pattern" to run matching tests. --test-only with test.only() for a temporary focused run; remove before finishing. --watch for local iteration. --test-concurrency <n> when file-level concurrency must be constrained. --test-reporter spec for readable local output. --experimental-test-coverage when native coverage is available in the target Node version. Test Structure Use ESM-style imports: import assert from "node:assert/strict" ; import { describe, test } from "node:test" ; import { parsePort } from "./parse-port.ts" ; describe ( "parsePort" , (): void => { test ( "accepts a valid TCP port" , (): void => { assert. equal ( parsePort ( "8080" ), 8080 ); }); test ( "rejects a non-numeric port" , (): void => { assert. deepEqual ( parsePort ( "abc" ), { type : "error" , error : "not-a-number" , }); }); }); Keep tests black-box: Assert observable return values, emitted values, written files, or explicit Result / Option errors. Do not assert private helper calls or implementation details. Prefer one structural assert.deepEqual(actual, expected) over many weak partial assertions. Use assert.equal() for primitives, assert.deepEqual() for records and arrays, and assert.match() for intentional text patterns. Import from node:assert/strict ; do not import legacy node:assert . Async Tests Return or await every async operation. Native tests fail on rejected promises when they are awaited by the test body. import assert from "node:assert/strict" ; import { test } from "node:test" ; import { readConfig } from "./read-config.ts" ; test ( "reads a config file" , async (): Promise < void > => { const config = await readConfig ( new URL ( "./fixtures/app.json" , import . meta . url ), ); assert. deepEqual (config, { mode : "test" , }); }); When testing promise rejection, use assert.rejects() and await it: await assert. rejects ( async (): Promise < void > => { await readConfig ( new URL ( "./fixtures/missing.json" , import . meta . url )); }, { name : "Error" , }, ); Fixtures And Node APIs Use Node standard modules for Node tests: import { mkdtemp, rm, writeFile } from "node:fs/promises" ; import { tmpdir } from "node:os" ; import { join } from "node:path" ; import { afterEach, test } from "node:test" ; Keep filesystem tests isolated: Create per-test temporary directories with mkdtemp(join(tmpdir(), "package-name-")) . Clean up with afterEach() or try / finally . Avoid shared fixture mutation. Read immutable fixtures from a fixtures/ directory. Do not depend on test execution order. Mocking Prefer dependency injection over mocks. When a mock is the simplest expression of behavior, use the native test context so cleanup is automatic: import assert from "node:assert/strict" ; import { test, type TestContext } from "node:test" ; test ( "calls the injected logger once" , ( context : TestContext ): void => { const loggedMessages : Array < string > = []; const log = context. mock . fn (( message : string ): void => { loggedMessages. push (message); }); log ( "ready" ); assert. equal (log. mock . callCount (), 1 ); assert. deepEqual (log. mock . calls [ 0 ]?. arguments , [ "ready" ]); assert. deepEqual (loggedMessages, [ "ready" ]); }); For timers, use context.mock.timers and advance time deterministically. Avoid real sleeps. Do Not Use expect , fake DOMs, or browser globals such as window and document . Transpiler-only TypeScript syntax assert.ok(actual) when a more precise assertion is available. assert.doesNotThrow() or assert.doesNotReject() as a substitute for asserting the real outcome. Focused tests, skipped tests, or random temporary files left behind after the run. Source Docs Node.js test runner: https://nodejs.org/api/test.html Node.js assert: https://nodejs.org/api/assert.html Running TypeScript natively: https://nodejs.org/learn/typescript/run-natively Node.js TypeScript API details: https://nodejs.org/api/typescript.html
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。