Conversation
|
Has the team read about snapshot testing in Jest yet? |
|
@j-f1 i am familiar with it! i haven't spent much time thinking how to apply them in this codebase tho, so if you have any thoughts, send 'em my way :) |
Co-Authored-By: Brendan Forster <github@brendanforster.com>
This reverts commit 9216fbd.
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,19 @@ | |||
| export const shell = { | |||
| moveItemToTrash: jest.fn(), | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -0,0 +1,19 @@ | |||
| export const shell = { | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| "@types/keytar": "^4.0.0", | ||
| "@types/legal-eagle": "^0.15.0", | ||
| "@types/mini-css-extract-plugin": "^0.2.0", | ||
| "@types/mocha": "^2.2.48", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| "klaw-sync": "^3.0.0", | ||
| "legal-eagle": "0.16.0", | ||
| "mini-css-extract-plugin": "^0.4.0", | ||
| "mocha": "^5.0.4", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| repositoryRoot, | ||
| 'node_modules', | ||
| '.bin', | ||
| 'xvfb-maybe' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| const Dexie = require('dexie') | ||
| Dexie.dependencies.indexedDB = require('fake-indexeddb') | ||
| Dexie.dependencies.IDBKeyRange = require('fake-indexeddb/lib/FDBKeyRange') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/test/setup-test-framework.ts
Outdated
| @@ -0,0 +1,3 @@ | |||
| /* eslint-disable strict */ | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/test/unit-test-env.ts
Outdated
| @@ -0,0 +1,16 @@ | |||
| /* eslint-disable strict */ | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
package.json
Outdated
| "electron-winstaller": "2.5.2" | ||
| "electron-winstaller": "2.5.2", | ||
| "jest": "^23.5.0", | ||
| "ts-jest": "^23.1.3" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
package.json
Outdated
| "electron-packager": "^12.0.0", | ||
| "electron-winstaller": "2.5.2" | ||
| "electron-winstaller": "2.5.2", | ||
| "jest": "^23.5.0", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| "test:unit": "cross-env ELECTRON_RUN_AS_NODE=1 node_modules/.bin/electron ./node_modules/jest/bin/jest --config ./jest.config.js", | ||
| "test:unit:cov": "yarn test:unit --coverage", | ||
| "test:script": "mocha -P ./tsonfig.json -t 10000 --require ts-node/register script/changelog/test/*.ts", | ||
| "test": "yarn test:unit --runInBand && yarn test:script && yarn test:integration", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/test/unit-test-env.ts
Outdated
| // ensuring Electron doesn't attach to the current console session (Windows only) | ||
| ELECTRON_NO_ATTACH_CONSOLE: '1', | ||
| // speed up ts-node usage by using the new transpile-only mode | ||
| TS_NODE_TRANSPILE_ONLY: 'true', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/test/setup-test-framework.ts
Outdated
| @@ -0,0 +1,4 @@ | |||
| 'use strict' | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
package.json
Outdated
| @@ -156,6 +158,8 @@ | |||
| "electron-builder": "20.27.1", | |||
| "electron-mocha": "^6.0.1", | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/test/unit-test-env.ts
Outdated
| @@ -0,0 +1,17 @@ | |||
| 'use strict' | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@shiftkey i tried removing the $ yarn lint
yarn run v1.9.4
$ yarn lint:src && yarn lint:prettier
$ yarn tslint && yarn eslint-check && yarn eslint
$ tslint -p .
$ eslint --print-config .eslintrc.* | eslint-config-prettier-check
No rules that are unnecessary or conflict with Prettier were found.
$ ts-node -P script/tsconfig.json script/eslint.ts
/Users/outofambit/GitHub/desktop/app/test/setup-test-framework.ts
2:1 error Use the global form of 'use strict' strict
/Users/outofambit/GitHub/desktop/app/test/unit-test-env.ts
1:1 error Use the global form of 'use strict' strictany ideas? i've tried a lot of stuff but am getting nowhere. |
I believe this is down to I can workaround this by adding an Three other workaround ideas I had:
diff --git a/app/test/setup-test-framework.ts b/app/test/setup-test-framework.ts
index e2baa26f0..36615fc18 100644
--- a/app/test/setup-test-framework.ts
+++ b/app/test/setup-test-framework.ts
@@ -1,4 +1,4 @@
-'use strict'
+/* eslint-disable strict */
// set test timeout to 10s
jest.setTimeout(10000)
diff --git a/app/test/unit-test-env.ts b/app/test/unit-test-env.ts
index 1088212de..a315028ef 100644
--- a/app/test/unit-test-env.ts
+++ b/app/test/unit-test-env.ts
@@ -1,4 +1,4 @@
-'use strict'
+/* eslint-disable strict */
const environmentVariables = {
// setting commit information so that tests don't need to rely on global config
diff --git a/app/test/.eslintrc.yml b/app/test/.eslintrc.yml
index 37d751d0d..38cf443ed 100644
--- a/app/test/.eslintrc.yml
+++ b/app/test/.eslintrc.yml
@@ -1,3 +1,4 @@
rules:
# throws with Chai
no-unused-expressions: off
+ strict: off
|
aka "gawd, don't be so strict"
|
🍏 |
shiftkey
left a comment
There was a problem hiding this comment.
Looks great @outofambit! I've opened #5496 to track writing some docs on this broad area, but that doesn't need to hold up this PR.



Goals
Implementation
scripts/unit-test.tsinto configuration/setup files used by jest (see jest.config.js)__mocks__/electron.ts)Discussion
had a couple disagreements with the linter that could be cleaned up betterone outstanding issue with VSTS regarding git config location (still looking into this)