generated at
fast-check







ts
fc.assert( fc.property(fc.string(), fc.string(), fc.string(), (a, b, c) => { return contains(a + b + c, b); }), );
3つのstring値を生成してる




fast-checkによってOSSのバグが見つかった実例





Vitestとの連携
特別な設定は不要そう
普通に、 test(..) の中で fc.assert を呼べば良い
global settings
生成するケース数とか
1つ懸念点はIn-source testingに抵抗があるなmrsekut







Command pattern的なシステムとかreducerを使う系のもののテストという感じmrsekut
テスト用にもCommandとその事前条件を定義しておき、事前条件を満たすものだけを、ランダムに投げていくテスト
ts
class AddBookNewCommand implements fc.Command<Model, BookRepository> { constructor(readonly value: Book) {} check = (m: Readonly<Model>) => { return !hasIsbn(m, this.value.isbn); }; async run(m: Model, r: BookRepository): Promise<void> { await r.addBook( this.value.isbn, this.value.title, this.value.author, this.value.owned, this.value.available ); m.set(this.value.isbn, this.value); } toString = () => `AddBookNew (${this.value.isbn})`; }
classで作るんだ



introduction
core-blocks
properties.md
advanced
fake-data.md
fuzzing.md
model-based-testing.md
race-conditions.md
configuration
custom-reports.md
global-settings.md
index.md
larger-entries-by-default.md
timeouts.md
user-definable-values.md
ecosystem.md
tutorials
quick-start
detect-race-conditions
index.md
multiple-batches-of-calls.mdx
one-step-closer-to-real-usages.mdx
snippets.mjs
snippets.spec.mjs
the-missing-part.mdx
wrapping-up.mdx
your-first-race-condition-test.mdx
index.md