diff --git a/packages/@n8n_io/eslint-config/base.js b/packages/@n8n_io/eslint-config/base.js index 700bc8c770..20bc0ec1ac 100644 --- a/packages/@n8n_io/eslint-config/base.js +++ b/packages/@n8n_io/eslint-config/base.js @@ -452,8 +452,11 @@ const config = (module.exports = { }, { files: ['test/**/*.ts'], - // TODO: Remove these rules: { + 'n8n-local-rules/no-skipped-tests': + process.env.NODE_ENV === 'development' ? 'warn' : 'error', + + // TODO: Remove these '@typescript-eslint/await-thenable': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/naming-convention': 'off', diff --git a/packages/@n8n_io/eslint-config/local-rules.js b/packages/@n8n_io/eslint-config/local-rules.js index 3d085b7731..60f15de392 100644 --- a/packages/@n8n_io/eslint-config/local-rules.js +++ b/packages/@n8n_io/eslint-config/local-rules.js @@ -170,6 +170,46 @@ module.exports = { }, }, + 'no-skipped-tests': { + meta: { + type: 'problem', + docs: { + description: 'Tests must not be skipped.', + recommended: 'error', + }, + messages: { + removeSkip: 'Remove `.skip()` call', + removeOnly: 'Remove `.only()` call', + }, + fixable: 'code', + }, + create(context) { + const TESTING_FUNCTIONS = new Set(['test', 'it', 'describe']); + const SKIPPING_METHODS = new Set(['skip', 'only']); + const toMessageId = (s) => 'remove' + s.charAt(0).toUpperCase() + s.slice(1); + + return { + MemberExpression(node) { + if ( + node.object.type === 'Identifier' && + TESTING_FUNCTIONS.has(node.object.name) && + node.property.type === 'Identifier' && + SKIPPING_METHODS.has(node.property.name) + ) { + context.report({ + messageId: toMessageId(node.property.name), + node, + fix: (fixer) => { + const [start, end] = node.property.range; + return fixer.removeRange([start - '.'.length, end]); + }, + }); + } + }, + }; + }, + }, + 'no-interpolation-in-regular-string': { meta: { type: 'problem', diff --git a/packages/cli/test/integration/commands/reset.cmd.test.ts b/packages/cli/test/integration/commands/reset.cmd.test.ts index 49cc20a733..8de3d43721 100644 --- a/packages/cli/test/integration/commands/reset.cmd.test.ts +++ b/packages/cli/test/integration/commands/reset.cmd.test.ts @@ -26,6 +26,7 @@ afterAll(async () => { await testDb.terminate(); }); +// eslint-disable-next-line n8n-local-rules/no-skipped-tests test.skip('user-management:reset should reset DB to default user state', async () => { await testDb.createUser({ globalRole: globalOwnerRole }); diff --git a/packages/cli/test/integration/eventbus.test.ts b/packages/cli/test/integration/eventbus.test.ts index 62106557fe..d6c1c84c8f 100644 --- a/packages/cli/test/integration/eventbus.test.ts +++ b/packages/cli/test/integration/eventbus.test.ts @@ -177,6 +177,7 @@ test('GET /eventbus/destination all returned destinations should exist in eventb }); // this test (presumably the mocking) is causing the test suite to randomly fail +// eslint-disable-next-line n8n-local-rules/no-skipped-tests test.skip('should send message to syslog', async () => { const testMessage = new EventMessageGeneric({ eventName: 'n8n.test.message' as EventNamesTypes, @@ -217,6 +218,7 @@ test.skip('should send message to syslog', async () => { }); }); +// eslint-disable-next-line n8n-local-rules/no-skipped-tests test.skip('should confirm send message if there are no subscribers', async () => { const testMessageUnsubscribed = new EventMessageGeneric({ eventName: 'n8n.test.unsub' as EventNamesTypes, diff --git a/packages/cli/test/integration/publicApi/executions.test.ts b/packages/cli/test/integration/publicApi/executions.test.ts index 8e00d46994..1165069666 100644 --- a/packages/cli/test/integration/publicApi/executions.test.ts +++ b/packages/cli/test/integration/publicApi/executions.test.ts @@ -245,6 +245,7 @@ describe('GET /executions', () => { }); // failing on Postgres and MySQL - ref: https://github.com/n8n-io/n8n/pull/3834 + // eslint-disable-next-line n8n-local-rules/no-skipped-tests test.skip('should paginate two executions', async () => { const workflow = await testDb.createWorkflow({}, owner);