Skip to content

Commit

Permalink
Merge pull request #1803 from MetRonnie/eslint-no-console
Browse files Browse the repository at this point in the history
Re-enable ESLint `no-console` & move Cypress component tests to `tests/` dir
  • Loading branch information
oliver-sanders authored Jan 13, 2025
2 parents 91b07b9 + 52eac3a commit 3b78caa
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 21 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ module.exports = {
functions: 'only-multiline',
},
],
'no-console': [
'error',
{
allow: ['warn', 'error']
}
],
'template-curly-spacing': [
'off'
],
Expand All @@ -60,6 +66,6 @@ module.exports = {
],
'cypress/unsafe-to-chain-command': [
'off'
]
],
},
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
selenium-debug.log*
vite.config.*.timestamp*

# Coverage
.nyc_output/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ There are three groups of tests:
* Unit tests
* Simple unit tests for individual functions and classes.
* **Framework:** [Vitest](https://vitest.dev/)
* **Assertions:** [Chai](https://www.chaijs.com/)/[Jest](https://jestjs.io/docs/expect)
* **Assertions:** [Chai](https://www.chaijs.com/)/[Vitest](https://vitest.dev/api/expect.html)
* **Path:** `tests/unit`
* **Command:** `yarn run test:unit` (watches by default, only re-runs changed file)
* (To prevent watching, use `yarn vitest run`)
* Component tests
* In-browser tests which mount a single Vue component standalone.
* **Framework:** [Cypress](https://docs.cypress.io/guides/overview/why-cypress)
* **Assertions:** Chai
* **Path:** `cypress/component`
* **Path:** `tests/component`
* **Command:** `yarn run test:component`
* (For "headless" mode use `yarn cypress run --component --config video=false`)
* End to end tests
Expand Down
12 changes: 4 additions & 8 deletions cypress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ module.exports = defineConfig({
mode: 'development',
})
)

return Object.assign({}, config, {
fixturesFolder: 'tests/e2e/fixtures',
specPattern: 'tests/e2e/specs',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
supportFile: 'tests/e2e/support/index.js'
})
return config
},
specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'tests/e2e/support/index.js'
Expand All @@ -56,6 +49,9 @@ module.exports = defineConfig({
require('@cypress/code-coverage/task')(on, config)
return config
},
specPattern: 'tests/component/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'tests/component/support/index.js',
indexHtmlFile: 'tests/component/support/component-index.html'
},

env: {
Expand Down
1 change: 0 additions & 1 deletion src/components/graphqlFormGenerator/components/vuetify.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ export function getComponentProps (gqlType, namedTypes, kinds) {
if (ret) {
return ret
}
// eslint-disable-next-line no-console
console.warn(`Falling back to string for type: ${name}, kind: ${kind}`)
return namedTypes.String
}
4 changes: 1 addition & 3 deletions src/services/workflow.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class WorkflowService {
})
} catch (err) {
console.error(err)
// eslint-disable-next-line no-console
console.log('retrying introspection query')
await new Promise(resolve => setTimeout(resolve, 2000))
return this.loadTypes()
Expand Down Expand Up @@ -242,7 +243,6 @@ class WorkflowService {
callback.init(store, errors)
for (const error of errors) {
store.commit('SET_ALERT', new Alert(error[0], 'error'), { root: true })
// eslint-disable-next-line no-console
console.warn(...error)
subscription.handleViewState(ViewState.ERROR, error('Error presetting view state'))
}
Expand Down Expand Up @@ -358,7 +358,6 @@ class WorkflowService {
new Alert(error[0], 'error'),
{ root: true }
)
// eslint-disable-next-line no-console
console.warn(...error)
}
},
Expand Down Expand Up @@ -423,7 +422,6 @@ class WorkflowService {
unsubscribe (query, uid) {
const subscription = this.subscriptions[query.name]
if (!subscription) {
// eslint-disable-next-line no-console
console.warn(`Could not unsubscribe [${query.name}]: Not Found`)
return
}
Expand Down
1 change: 1 addition & 0 deletions src/store/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const actions = {
if (alert?.color === 'error') {
console.error(alert.err)
} else if (alert) {
// eslint-disable-next-line no-console
console.log(alert.err)
}
commit('SET_ALERT', alert)
Expand Down
1 change: 0 additions & 1 deletion src/utils/aotf.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,6 @@ function _mutateSuccess (message) {
async function _mutateError (mutationName, err, response) {
// log the response
if (response) {
// eslint-disable-next-line no-console
console.error('mutation response', response)
}

Expand Down
1 change: 0 additions & 1 deletion src/views/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ export default {
// something went wrong, allow the layout to retry later
this.graphID = null
this.updating = false
// eslint-disable-next-line no-console
console.error(e)
return
}
Expand Down
25 changes: 25 additions & 0 deletions tests/component/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

module.exports = {
plugins: [
'cypress'
],
env: {
'cypress/globals': true
},
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions tests/e2e/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -22,7 +22,4 @@ module.exports = {
env: {
'cypress/globals': true
},
rules: {
strict: 'off'
}
}

0 comments on commit 3b78caa

Please sign in to comment.