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: ...@@ -95,7 +95,8 @@ rules:
order: ignore order: ignore
overrides: overrides:
- files: - files:
- '**/spec/**/*' - 'ee/spec/frontend*/**/*'
- 'spec/frontend*/**/*'
rules: rules:
'@gitlab/require-i18n-strings': off '@gitlab/require-i18n-strings': off
'@gitlab/no-runtime-template-compiler': off '@gitlab/no-runtime-template-compiler': off
...@@ -103,6 +104,8 @@ overrides: ...@@ -103,6 +104,8 @@ overrides:
- error - error
- selector: CallExpression[callee.object.name=/(wrapper|vm)/][callee.property.name="setData"] - selector: CallExpression[callee.object.name=/(wrapper|vm)/][callee.property.name="setData"]
message: 'Avoid using "setData" on VTU wrapper' 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: - files:
- 'config/**/*' - 'config/**/*'
- 'scripts/**/*' - 'scripts/**/*'
......
...@@ -121,7 +121,7 @@ describe('IDE clientside preview', () => { ...@@ -121,7 +121,7 @@ describe('IDE clientside preview', () => {
it('pings usage success', async () => { it('pings usage success', async () => {
dispatchCodesandboxReady(); dispatchCodesandboxReady();
await wrapper.vm.$nextTick(); await nextTick();
expect(storeClientsideActions.pingUsage).toHaveBeenCalledTimes(2); expect(storeClientsideActions.pingUsage).toHaveBeenCalledTimes(2);
expect(storeClientsideActions.pingUsage).toHaveBeenCalledWith( expect(storeClientsideActions.pingUsage).toHaveBeenCalledWith(
expect.anything(), 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