ci: Forbid skipping tests (no-changelog) (#6199)

This commit is contained in:
Iván Ovejero 2023-05-24 09:45:37 +02:00 committed by GitHub
parent e046f656fe
commit fe937a0ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 1 deletions

View file

@ -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',

View file

@ -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',

View file

@ -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 });

View file

@ -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,

View file

@ -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);