Commit 2c3fad40 authored by Stanislav Lashmanov's avatar Stanislav Lashmanov Committed by Mark Florian

Prevent .$nextTick usage in tests

The exception is `this.$nextTick()`, which is allowed because a component
definition/implementation may legitimately call its _own_ method. This
rule is about preventing test code from calling that instance method.

Addresses https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/47.
parent 5185d156
......@@ -95,7 +95,8 @@ rules:
order: ignore
overrides:
- files:
- '**/spec/**/*'
- 'ee/spec/frontend*/**/*'
- 'spec/frontend*/**/*'
rules:
'@gitlab/require-i18n-strings': off
'@gitlab/no-runtime-template-compiler': off
......@@ -103,6 +104,8 @@ overrides:
- error
- selector: CallExpression[callee.object.name=/(wrapper|vm)/][callee.property.name="setData"]
message: 'Avoid using "setData" on VTU wrapper'
- selector: MemberExpression[object.type!='ThisExpression'][property.type='Identifier'][property.name='$nextTick']
message: 'Using $nextTick from a component instance is discouraged. Import nextTick directly from the Vue package.'
- files:
- 'config/**/*'
- 'scripts/**/*'
......
......@@ -121,7 +121,7 @@ describe('IDE clientside preview', () => {
it('pings usage success', async () => {
dispatchCodesandboxReady();
await wrapper.vm.$nextTick();
await nextTick();
expect(storeClientsideActions.pingUsage).toHaveBeenCalledTimes(2);
expect(storeClientsideActions.pingUsage).toHaveBeenCalledWith(
expect.anything(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment