deno_std
deno_std copied to clipboard
tracking: format test names
Ref: https://github.com/denoland/deno_std/issues/2553#issuecomment-1784006070
This issue tracks the implementation progress of adapting the following format for test names in each sub-module:
<symbol>() <description> // E.g. ensureDir() creates the directory if it doesn't exist
- [x] archive
- [x] assert
- [x] async
- [x] bytes
- [x] cli
- [ ] collections
- [x] console
- [x] crypto
- [ ] csv
- [x] datetime
- [ ] dotenv
- [ ] encoding
- [ ] flags
- [ ] fmt
- [ ] front_matter
- [x] fs
- [ ] html
- [ ] http
- [ ] io
- [ ] json
- [ ] jsonc
- [ ] log
- [ ] media_types
- [ ] msgpack
- [x] path
- [ ] permissions
- [x] regexp
- [ ] semver
- [ ] signal
- [ ] streams
- [ ] testing
- [ ] toml
- [ ] ulid
- [ ] url
- [x] uuid
- [ ] wasi
- [ ] yaml
I'm working on fs - should be done tomorrow
https://github.com/denoland/deno-docs/blob/2c90cc2eca70c484e5fbfc61d256bf7342a2e95e/runtime/manual/references/contributing/style_guide.md?plain=1#L310-L327
maybe the test name rules could be documented in deno manual. should I open PR/issue?
Ah, yes. We do need to add something in the contributing guidelines. A PR would be welcome!
Is there a way to make the linter enforce this?
Would it be worth using the bdd.ts describe blocks to define the subject under test?
Deno.test({
name: "[std/datetime] isLeap",
fn() {
assert(isLeap(1992));
assert(isLeap(2000));
assert(!isLeap(2003));
assert(!isLeap(2007));
assert(!isLeap(new Date("1970-01-02")));
assert(isLeap(new Date("1972-01-02")));
assert(isLeap(new Date("2000-01-02")));
assert(!isLeap(new Date("2100-01-02")));
},
});
to
import { describe, it } from "../testing/bdd.ts";
describe("isLeap()", () => {
it("identifies leap years for numbers", () => {
assert(isLeap(1992));
assert(isLeap(2000));
assert(!isLeap(2003));
assert(!isLeap(2007));
});
it("identifies leap years for Date instances", () => {
assert(!isLeap(new Date("1970-01-02")));
assert(isLeap(new Date("1972-01-02")));
assert(isLeap(new Date("2000-01-02")));
assert(!isLeap(new Date("2100-01-02")));
});
});
It forces the format you're after: Subject under test and description of desired behaviour
The big downside is that you loose the test integration in vscode:
docs: unified test names
I don't think so.
Would it be worth using the bdd.ts describe blocks to define the subject under test?
The current approach of using std/assert
with Deno.test()
(and steps, if needed) already works fine.
For anyone wanting to contribute, only std/testing
remains.