Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clojure] test snippet triggered when typing -test for the deftest name #438

Open
practicalli-johnny opened this issue Jan 20, 2022 · 1 comment
Labels
seen PR was seen and initial feedback was given

Comments

@practicalli-johnny
Copy link

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

  1. Rename the test snippet to deftest or other name that will not expand from -test
  2. Update test snippet to postfix -test to the name automatically (see deftest example below)
  3. Hope everyone remembers to press space after the -test name, before pressing TAB

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.

@AndreaCrotti
Copy link
Owner

Hi @practicalli-john , so I just tried to reproduce the issue but I can't actually reproduce it.
I do test TAB hello-test TAB and it just goes to the next placeholder.
Do you have any yasnippet settings maybe that might cause this behaviour?
I just had a couple of configs for yasnippet but I checked and even changing them the behaviour still doesn't change.

@AndreaCrotti AndreaCrotti added the seen PR was seen and initial feedback was given label Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seen PR was seen and initial feedback was given
Projects
None yet
Development

No branches or pull requests

2 participants