A curated list of awesome Intellij Live Templates
Name: iteach
it.each`
note | given | expected
${'should'} | ${{}} | ${{}}
${'should'} | ${{}} | ${{}}
`('$note given: $given expected: $expected ', async ({given, expected}) => {
});
<template name="iteach" value="it.each` note | $NAME1$ | $NAME2$ ${'should'} | ${$VALUE1$} | ${$VALUE2$} ${'should'} | ${$VALUE1$} | ${$VALUE2$} `('$note $NAME1$: $$$NAME1$ $NAME2$: $$$NAME2$ ', async ({$NAME1$, $NAME2$}) => { $END$ });" description="generates it each block" toReformat="false" toShortenFQNames="true">
<variable name="NAME1" expression=""given"" defaultValue="" alwaysStopAt="true" />
<variable name="VALUE1" expression=""{}"" defaultValue="" alwaysStopAt="true" />
<variable name="NAME2" expression=""expected"" defaultValue="" alwaysStopAt="true" />
<variable name="VALUE2" expression=""{}"" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JS_STATEMENT" value="true" />
</context>
</template>
Name: jmck
From (if selected)
'../src/example/path.ts'
To
jest.mock('../src/example/path.ts', () => ({
__esModule: true,
default: jest.fn()
}));
<template name="jmck" value="jest.mock($SELECTION$, () => ({ __esModule: true, $END$default: jest.fn() }));" description="add a mock stub" toReformat="false" toShortenFQNames="true">
<context>
<option name="JAVA_SCRIPT" value="true" />
<option name="JSX_HTML" value="false" />
<option name="JS_CLASS" value="false" />
<option name="JS_EXPRESSION" value="false" />
</context>
</template>
Name: BEAN
@Bean
$CLASS_NAME$ $beanName$($PARAMETERS$) {
return new $CLASS_NAME$($parametersToPass$);
}
<template name="BEAN" value="@org.springframework.context.annotation.Bean $CLASS_NAME$ $beanName$($PARAMETERS$) { return new $CLASS_NAME$($parametersToPass$); }" description="Create a default Bean for a class." toReformat="true" toShortenFQNames="true" useStaticImport="true">
<variable name="CLASS_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="beanName" expression="camelCase(CLASS_NAME)" defaultValue="" alwaysStopAt="false" />
<variable name="PARAMETERS" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="parametersToPass" expression="regularExpression(PARAMETERS, "(^|,\\s*)\\S+\\s+", "$1")" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
Name: TEST
@Test
@DisplayName("$TEST_TITLE$")
void $TEST_NAME$() {
$END$
}
<template name="TEST" value="@org.junit.jupiter.api.Test @org.junit.jupiter.api.DisplayName("$TEST_TITLE$") void $TEST_NAME$() { $END$ }" description="Create a standard JUnit5 test." toReformat="false" toShortenFQNames="true">
<variable name="TEST_TITLE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="TEST_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
Name: ASSIS
assertThat($expression$, is($expected$));
<template name="ASSIS" value="org.hamcrest.MatcherAssert.assertThat($expression$, org.hamcrest.Matchers.is($expected$));" description="Hamcrest assertThat(x, is())" toReformat="false" toShortenFQNames="true" useStaticImport="true">
<variable name="expression" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="expected" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_EXPRESSION" value="true" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>