Skip to content

Commit 3b78caa

Browse files
Merge pull request #1803 from MetRonnie/eslint-no-console
Re-enable ESLint `no-console` & move Cypress component tests to `tests/` dir
2 parents 91b07b9 + 52eac3a commit 3b78caa

File tree

23 files changed

+42
-21
lines changed

23 files changed

+42
-21
lines changed

.eslintrc.cjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ module.exports = {
4040
functions: 'only-multiline',
4141
},
4242
],
43+
'no-console': [
44+
'error',
45+
{
46+
allow: ['warn', 'error']
47+
}
48+
],
4349
'template-curly-spacing': [
4450
'off'
4551
],
@@ -60,6 +66,6 @@ module.exports = {
6066
],
6167
'cypress/unsafe-to-chain-command': [
6268
'off'
63-
]
69+
],
6470
},
6571
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ npm-debug.log*
1818
yarn-debug.log*
1919
yarn-error.log*
2020
selenium-debug.log*
21+
vite.config.*.timestamp*
2122

2223
# Coverage
2324
.nyc_output/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ There are three groups of tests:
6969
* Unit tests
7070
* Simple unit tests for individual functions and classes.
7171
* **Framework:** [Vitest](https://vitest.dev/)
72-
* **Assertions:** [Chai](https://www.chaijs.com/)/[Jest](https://jestjs.io/docs/expect)
72+
* **Assertions:** [Chai](https://www.chaijs.com/)/[Vitest](https://vitest.dev/api/expect.html)
7373
* **Path:** `tests/unit`
7474
* **Command:** `yarn run test:unit` (watches by default, only re-runs changed file)
7575
* (To prevent watching, use `yarn vitest run`)
7676
* Component tests
7777
* In-browser tests which mount a single Vue component standalone.
7878
* **Framework:** [Cypress](https://docs.cypress.io/guides/overview/why-cypress)
7979
* **Assertions:** Chai
80-
* **Path:** `cypress/component`
80+
* **Path:** `tests/component`
8181
* **Command:** `yarn run test:component`
8282
* (For "headless" mode use `yarn cypress run --component --config video=false`)
8383
* End to end tests

cypress.config.cjs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@ module.exports = defineConfig({
3333
mode: 'development',
3434
})
3535
)
36-
37-
return Object.assign({}, config, {
38-
fixturesFolder: 'tests/e2e/fixtures',
39-
specPattern: 'tests/e2e/specs',
40-
screenshotsFolder: 'tests/e2e/screenshots',
41-
videosFolder: 'tests/e2e/videos',
42-
supportFile: 'tests/e2e/support/index.js'
43-
})
36+
return config
4437
},
4538
specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}',
4639
supportFile: 'tests/e2e/support/index.js'
@@ -56,6 +49,9 @@ module.exports = defineConfig({
5649
require('@cypress/code-coverage/task')(on, config)
5750
return config
5851
},
52+
specPattern: 'tests/component/**/*.cy.{js,jsx,ts,tsx}',
53+
supportFile: 'tests/component/support/index.js',
54+
indexHtmlFile: 'tests/component/support/component-index.html'
5955
},
6056

6157
env: {

src/components/graphqlFormGenerator/components/vuetify.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ export function getComponentProps (gqlType, namedTypes, kinds) {
206206
if (ret) {
207207
return ret
208208
}
209-
// eslint-disable-next-line no-console
210209
console.warn(`Falling back to string for type: ${name}, kind: ${kind}`)
211210
return namedTypes.String
212211
}

src/services/workflow.service.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class WorkflowService {
167167
})
168168
} catch (err) {
169169
console.error(err)
170+
// eslint-disable-next-line no-console
170171
console.log('retrying introspection query')
171172
await new Promise(resolve => setTimeout(resolve, 2000))
172173
return this.loadTypes()
@@ -242,7 +243,6 @@ class WorkflowService {
242243
callback.init(store, errors)
243244
for (const error of errors) {
244245
store.commit('SET_ALERT', new Alert(error[0], 'error'), { root: true })
245-
// eslint-disable-next-line no-console
246246
console.warn(...error)
247247
subscription.handleViewState(ViewState.ERROR, error('Error presetting view state'))
248248
}
@@ -358,7 +358,6 @@ class WorkflowService {
358358
new Alert(error[0], 'error'),
359359
{ root: true }
360360
)
361-
// eslint-disable-next-line no-console
362361
console.warn(...error)
363362
}
364363
},
@@ -423,7 +422,6 @@ class WorkflowService {
423422
unsubscribe (query, uid) {
424423
const subscription = this.subscriptions[query.name]
425424
if (!subscription) {
426-
// eslint-disable-next-line no-console
427425
console.warn(`Could not unsubscribe [${query.name}]: Not Found`)
428426
return
429427
}

src/store/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const actions = {
4949
if (alert?.color === 'error') {
5050
console.error(alert.err)
5151
} else if (alert) {
52+
// eslint-disable-next-line no-console
5253
console.log(alert.err)
5354
}
5455
commit('SET_ALERT', alert)

src/utils/aotf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ function _mutateSuccess (message) {
908908
async function _mutateError (mutationName, err, response) {
909909
// log the response
910910
if (response) {
911-
// eslint-disable-next-line no-console
912911
console.error('mutation response', response)
913912
}
914913

src/views/Graph.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ export default {
709709
// something went wrong, allow the layout to retry later
710710
this.graphID = null
711711
this.updating = false
712-
// eslint-disable-next-line no-console
713712
console.error(e)
714713
return
715714
}

tests/component/.eslintrc.cjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
module.exports = {
19+
plugins: [
20+
'cypress'
21+
],
22+
env: {
23+
'cypress/globals': true
24+
},
25+
}

0 commit comments

Comments
 (0)