-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(jest-cypress): add ESLint config and TS support #117
Conversation
Hi there! I'm also using Quasar testing with Typescript, good that this is becoming part of the extension :) In the jest.config.js I exclude collecting coverage from index/types.ts files as well as '.d.ts' files, because that clutters the resulting coverage file. Maybe include that in here as well? Second we exclude the /src-ssr/ and /src/boot/ folders from the coverage, for that same reason, maybe add exclusions for other build modes as well?
And finally I have a question, why is the utils file still a .js and not a .ts? Is there a good reason for it? Because I'm using .ts files and maybe I shouldn't. Speaking of utils a moduleNameMapper for them could also be useful: That was it for now, hope it's useful! |
Hey there @Evertvdw! Nice suggestions, gonna integrate some in next beta release. Some comments:
|
Regarding mountQuasar, we are using a similar function extensively but have quite some trouble with seperating vueInstance and using quasar on them. Make sure you also create a test file in which you call that function twice and see if everything goes as expected the second time :) |
These are great features. |
@egyel it's already out as beta! Yet, |
@Evertvdw I checked again, current setup only collect coverage from I'll exclude |
Updated the beta to adapt to |
Coming from the mountQuasar discussion but shifting focus to Cypress; Looking further into this pull request it looks like you've got everything covered already! Though I wonder if you get the same type conflicts I do when running WAIT Compiling... 6:11:12 PM
• Compiling:
└── SPA ████████████████████ 100% done in 407 ms
DONE Compiled successfully in 416ms 6:11:12 PM
N App dir........... /project-dir
App URL........... http://localhost:8080
Dev mode.......... spa
Pkg quasar........ v1.13.2
Pkg @quasar/app... v2.0.9
Transpiled JS..... yes (Babel) - includes IE11 support
ERROR in /project-dir/test/cypress/integration/home.spec.ts(143,3):
TS2304: Cannot find name 'cy'.
ERROR in /project-dir/test/cypress/integration/home.spec.ts(161,1):
TS2304: Cannot find name 'context'.
ERROR in /project-dir/test/cypress/integration/home.spec.ts(200,3):
TS2304: Cannot find name 'specify'.
// and on and on.. It seems supportTS: {
tsLoaderConfig: {},
tsCheckerConfig: {
eslint: false,
},
}, which hides the errors on initial compile, but it still lints after modifying Vue components and recompiling I just tried to start from scratch to verify: quasar create starter
quasar ext add @quasar/testing
quasar ext add @quasar/testing-unit-jest@beta <-- 1.1.0-beta.6
quasar ext add @quasar/testing-e2e-cypress@beta <-- 1.0.0-beta.13 all with typescript support and minimal defaults. I wanted to note that the ? Please choose how to install required babel rules: Overwrite babel.config.js and use additional .babelrc
? Jest Unit testing will now be installed. Please choose additional options: Extra "scripts" in your package.json, TypeScript support, SFC webpack <test> loader
App · Updating /quasar.extensions.json for "@quasar/testing-unit-jest" extension ...
App · Running App Extension install script...
App · ⚠️ Extension(@quasar/testing-unit-jest): extendJsonFile() - "/starter/tsconfig.json" doesn't conform to JSON format: this could happen if you are trying to update flavoured JSON files (eg. JSON with Comments or JSON5). Skipping...
App · ⚠️ Extension(@quasar/testing-unit-jest): extendJsonFile() - The extension tried to apply these updates to "/starter/tsconfig.json" file: {"compilerOptions":{"esModuleInterop":true,"types":["quasar","jest"]}} I had to modify I confirmed that among other [default] lint warnings I do see cypress type warnings when running ERROR in /starter/test/cypress/integration/home.spec.ts(6,5):
TS2304: Cannot find name 'cy'.
ERROR in /starter/test/cypress/plugins/index.ts(17,29):
TS2694: Namespace 'Cypress' has no exported member 'PluginConfig'.
ERROR in /starter/test/cypress/support/commands.ts(34,28):
TS2315: Type 'Chainable' is not generic.
ERROR in /starter/test/cypress/support/commands.ts(60,1):
TS2708: Cannot use namespace 'Cypress' as a value.
ERROR in /starter/test/cypress/support/commands.ts(65,24):
TS7006: Parameter 'loc' implicitly has an 'any' type.
ERROR in /starter/test/cypress/support/commands.ts(66,22):
TS2339: Property 'to' does not exist on type 'JestMatchersShape<Matchers<void, any>, Matchers<Promise<void>, any>>'.
ERROR in /starter/test/cypress/support/commands.ts(74,1):
TS2708: Cannot use namespace 'Cypress' as a value.
ERROR in /starter/test/cypress/support/commands.ts(81,1):
TS2708: Cannot use namespace 'Cypress' as a value.
ERROR in /starter/test/cypress/support/index.ts(21,1):
TS2708: Cannot use namespace 'Cypress' as a value.
ERROR in /starter/test/cypress/support/index.ts(21,35):
TS7006: Parameter 'err' implicitly has an 'any' type. But again that may be more related to I haven't found any way around this yet. |
@Blfrg those errors where due to some problem I already fixed but not yet released.
That error is generated when your |
Here is a fresh > quasar create starter
___
/ _ \ _ _ __ _ ___ __ _ _ __
| | | | | | |/ _` / __|/ _` | '__|
| |_| | |_| | (_| \__ \ (_| | |
\__\_\\__,_|\__,_|___/\__,_|_|
? Project name (internal usage for dev) starter
? Project product name (must start with letter if building mobile apps) Quasar App
? Project description A Quasar Framework app
? Author Blfrg
? Pick your favorite CSS preprocessor: (can be changed later) Stylus
? Pick a Quasar components & directives import strategy: (can be changed later) Auto import
? Check the features needed for your project: ESLint (recommended), TypeScript, Vuex, Axios, Vue-i18n, IE11 support
? Pick a component style: Composition
? Pick an ESLint preset: Prettier
? Continue to install project dependencies after the project has been created? (recommended) NPM
Quasar CLI · Generated "starter". Here is the resulting {
"extends": "@quasar/app/tsconfig-preset",
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
}
} Here is adding
{
"extends": "@quasar/app/tsconfig-preset",
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
}
} Now I add > quasar ext add @quasar/testing-unit-jest@beta
? Please choose how to install required babel rules: Overwrite babel.config.js and use additional .babelrc
? Jest Unit testing will now be installed. Please choose additional options: Extra "scripts" in your package.json, TypeScript support, SFC webpack <test> loader
App · Updating /quasar.extensions.json for "@quasar/testing-unit-jest" extension ...
App · Running App Extension install script...
(node:733526) UnhandledPromiseRejectionWarning: SyntaxError: /starter/tsconfig.json: Unexpected token } in JSON at position 112
- parse
- loader.js:1171 Object.Module._extensions..json
internal/modules/cjs/loader.js:1171:22
- loader.js:985 Module.load
internal/modules/cjs/loader.js:985:32
- loader.js:878 Function.Module._load
internal/modules/cjs/loader.js:878:14
- loader.js:1025 Module.require
internal/modules/cjs/loader.js:1025:19
- helpers.js:72 require
internal/modules/cjs/helpers.js:72:18
- install.js:91
[starter]/[@quasar]/quasar-app-extension-testing-unit-jest/src/install.js:91:24
- Array.forEach
- install.js:58 module.exports
[starter]/[@quasar]/quasar-app-extension-testing-unit-jest/src/install.js:58:23
- Extension.js:339 Extension.__runInstallScript
[starter]/[@quasar]/app/lib/app-extension/Extension.js:339:11
(node:733526) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:733526) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. The error was much worse this time but helped lead me to a solution. {
"extends": "@quasar/app/tsconfig-preset",
"compilerOptions": {
"baseUrl": ".",
"target": "es5" <-- removed comma
}
} I was able to complete the That
To further confirm > npm run test:e2e
// ...
ERROR in /starter/test/cypress/support/index.ts(22,7):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
ERROR in /starter/node_modules/cypress/types/bluebird/index.d.ts(790,32):
TS2304: Cannot find name 'IterableIterator'.
ERROR in /starter/node_modules/cypress/types/chai/index.d.ts(840,49):
TS2304: Cannot find name 'ReadonlySet'.
ERROR in /starter/node_modules/cypress/types/chai/index.d.ts(840,66):
TS2304: Cannot find name 'ReadonlyMap'.
ERROR in /starter/test/cypress/support/index.ts(22,19):
TS2339: Property 'startsWith' does not exist on type 'string'.
// ... duplicates removed for brevity Note: Once quasar generates the files it clears the screen, but the cypress type errors are already there if you scroll up. I know this is a WIP and difficult to nail down. |
I merged the trailing comma removal, as it was the source of the error as you correctly identified
The last error you reported makes me think the issue is related to you having enabled IE support ( Update |
@IlCallo Thank you for the merge and the details! I confirmed the suggested change When I mentioned "quasar-testing extension is required" I meant in the case that someone uses the following: > quasar test --unit jest
App · ⚠️ Quasar App Extension "@quasar/testing" is missing...
> quasar test --e2e cypress
App · ⚠️ Quasar App Extension "@quasar/testing" is missing... I normally use On that note, when everything is properly installed; I assume this has to do with the new script which starts dev+e2e (nice addition BTW!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IlCallo I'm not sure if this review
(status: Pending) is visible.
Please consider the proposed changes (Cypress 5.x), thank you.
Unluckily I can only quote myself... Taking over a codebase written by someone else takes time :) |
Beta docs live at https://ilcallo.github.io/quasar-testing/ |
What kind of change does this PR introduce? (check at least one)
If you are adding a new test runner, have you...? (check all)
/packages/base/runners.json
?/README.md
?baseline.spec.vue
?Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch and not themaster
branchfix: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
@webnoob and @outofmemoryagain
Up for you to beta-test!
Testing on Windows and Mac is missing.
Gonna work on creating a better (and type-safe)
mountQuasar
tomorrowCloses #99
Closes #95
Partially address #91 (just Jest and Cypress)
Closes #48 (doesn't actually cover all harnesses, but most of Jest related stuff there has been integrated)