-
Notifications
You must be signed in to change notification settings - Fork 480
Description
A very common convention in Clojure.test is to name unit tests ending in -test
, which unfortunately can trigger yasnippet expansion
Reproduction of issue
Enable Yasnippets with this repository as a source of snippets
Type test
and call yas-expand
to generate a deftest
form with the cursor placed on the deftest name as it matches the test
snippet.
Type the test name, i.e. addition-test
and press TAB
to go to the next tab stop
Rather than jumping to the next tab stop, the test
part of the deftest name is expanded into a deftest form, creating a second defttest form within the first.
If a space is typed after the deftest -test
name then TAB
does not expand to another deftest form.
Suggested options
- Rename the
test
snippet todeftest
or other name that will not expand from-test
- Update
test
snippet to postfix-test
to the name automatically (seedeftest
example below) - Hope everyone remembers to press space after the
-test
name, before pressingTAB
Additional point
The (testing ,,,)
form is typically used within a deftest
to organise assertions, (is ,,,)
expressions, into logical groups. This supports more specific test reports when tests fail.
Consider adding testing to a snippet that generated a deftest, for example
(deftest ${1:name}-test
(testing "${2:Context of the test assertions}"$>
(is (= ${3:assertion-values}))$4))$>
$0
Tab stop 2 and 3 text will be substituted when visiting that tab stop.