Skip to content
代码片段 群组 项目
提交 2c3fad40 编辑于 作者: Stanislav Lashmanov's avatar Stanislav Lashmanov 提交者: 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.
上级 5185d156
No related branches found
No related tags found
无相关合并请求
......@@ -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(),
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册