(after-all & body)
Runs body
after all tests in the current file.
Runs `body` after all tests in the current file.
(after-each & body)
Runs body
after each test in the current scope.
Runs `body` after each test in the current scope.
(before-all & body)
Runs body
before all tests in the current file.
Runs `body` before all tests in the current file.
(before-each & body)
Runs body
before each test in the current scope.
Runs `body` before each test in the current scope.
(describe name & body)
Describes a block of tests. Any before-each
/after-each
inside of this block will be scoped to it.
Example:
(describe "some-fn"
(before-each (do-something))
(after-each (cleanup))
(it "does something" ...))
Describes a block of tests. Any `before-each`/`after-each` inside of this block will be scoped to it. Example: ``` (describe "some-fn" (before-each (do-something)) (after-each (cleanup)) (it "does something" ...)) ```
(each seq-exprs name & body)
A nicer way to create the same test case for multiple inputs. Essentially doseq
for
test cases, except the second argument is the description passed into the generated it
block.
Example:
(each [[text num] ["hello" 1]
["world" 2]
["foo" 3]]
(str "should call the function with " text " and " num)
(do-something-with text num))
Above generates:
(it "should call the function with hello and 1" (do-something-with "hello" 1))
(it "should call the function with world and 2" (do-something-with "world" 2))
(it "should call the function with foo and 3" (do-something-with "foo" 3))
A nicer way to create the same test case for multiple inputs. Essentially `doseq` for test cases, except the second argument is the description passed into the generated `it` block. Example: ``` (each [[text num] ["hello" 1] ["world" 2] ["foo" 3]] (str "should call the function with " text " and " num) (do-something-with text num)) ``` Above generates: ``` (it "should call the function with hello and 1" (do-something-with "hello" 1)) (it "should call the function with world and 2" (do-something-with "world" 2)) (it "should call the function with foo and 3" (do-something-with "foo" 3)) ```
(is form)
A generic assertion macro for Jest. Asserts that form
is truthy.
Note: This does not work exactly like clojure.test/is
. It does not accept thrown?
or thrown-with-msg?
.
Example:
(it "should be true" (is (= true (my-fn :some-keyword)))
A generic assertion macro for Jest. Asserts that `form` is truthy. Note: This does not work exactly like `clojure.test/is`. It does not accept `thrown?` or `thrown-with-msg?`. Example: (it "should be true" (is (= true (my-fn :some-keyword)))
(only name & body)
Like it
but is the only test that runs in this file.
Like `it` but is the only test that runs in this file.
(only-each seq-exprs name & body)
A combination of each
and only
.
A combination of `each` and `only`.
(skip name & body)
Like it
, but skips the test. Can be used to temporarily skip flaky tests.
Like `it`, but skips the test. Can be used to temporarily skip flaky tests.
(spy)
(spy mock-implementation)
An unused spy, optionally taking mock-implementation
, a function that will be called
when this spy is called.
An unused spy, optionally taking `mock-implementation`, a function that will be called when this spy is called.
(spy-on object method-name)
(spy-on object method-name access-type)
Creates a mock function similar to jest.fn but also tracks calls to (.-method-name object).
Essentially it overrides a specific property on an object while preserving the original function.
See https://jestjs.io/docs/jest-object#jestspyonobject-methodname for more details.
Creates a mock function similar to jest.fn but also tracks calls to (.-method-name object). Essentially it overrides a specific property on an object while preserving the original function. See https://jestjs.io/docs/jest-object#jestspyonobject-methodname for more details.
(todo name)
Similar to a semi TODO, allows writing the name of a test case before writing the actual case.
Similar to a semi TODO, allows writing the name of a test case before writing the actual case.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close