bahmutov / local-cypress Goto Github PK
View Code? Open in Web Editor NEWUse Cypress without global objects
Home Page: https://glebbahmutov.com/blog/local-cypress/
Use Cypress without global objects
Home Page: https://glebbahmutov.com/blog/local-cypress/
import { cy } from "local-cypress"
I got an error in VSCode:
Cannot find module 'local-cypress'. Did you mean to set the 'moduleResolution' option to 'node',
or to add aliases to the 'paths' option? ts(2792)
So I added "moduleResolution": "node"
to tsconfig.json
.
{
"compilerOptions": {
"moduleResolution": "node",
...
},
...
}
I hope this configuration requirement to be mentioned in local-cypress
documentation.
If we enable "skipLibCheck": true
in https://github.com/bahmutov/local-cypress-and-jest-typescript-example then we get the test function type errors
$ npm run lint
> [email protected] lint /Users/gleb/git/local-cypress-and-jest-typescript-example
> tsc --project tsconfig.lint.json
node_modules/@types/mocha/index.d.ts:2680:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
2680 declare var beforeEach: Mocha.HookFunction;
~~~~~~~~~~
node_modules/@types/jest/index.d.ts:35:13
35 declare var beforeEach: jest.Lifecycle;
~~~~~~~~~~
'beforeEach' was also declared here.
node_modules/@types/mocha/index.d.ts:2698:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'afterEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
2698 declare var afterEach: Mocha.HookFunction;
~~~~~~~~~
node_modules/@types/jest/index.d.ts:37:13
37 declare var afterEach: jest.Lifecycle;
~~~~~~~~~
'afterEach' was also declared here.
node_modules/@types/mocha/index.d.ts:2714:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'describe' must be of type 'Describe', but here has type 'SuiteFunction'.
2714 declare var describe: Mocha.SuiteFunction;
~~~~~~~~
node_modules/@types/jest/index.d.ts:38:13
38 declare var describe: jest.Describe;
~~~~~~~~
'describe' was also declared here.
node_modules/@types/mocha/index.d.ts:2735:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xdescribe' must be of type 'Describe', but here has type 'PendingSuiteFunction'.
2735 declare var xdescribe: Mocha.PendingSuiteFunction;
~~~~~~~~~
node_modules/@types/jest/index.d.ts:40:13
40 declare var xdescribe: jest.Describe;
~~~~~~~~~
'xdescribe' was also declared here.
node_modules/@types/mocha/index.d.ts:2749:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'it' must be of type 'It', but here has type 'TestFunction'.
2749 declare var it: Mocha.TestFunction;
~~
node_modules/@types/jest/index.d.ts:41:13
41 declare var it: jest.It;
~~
'it' was also declared here.
node_modules/@types/mocha/index.d.ts:2763:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'test' must be of type 'It', but here has type 'TestFunction'.
2763 declare var test: Mocha.TestFunction;
~~~~
node_modules/@types/jest/index.d.ts:44:13
44 declare var test: jest.It;
~~~~
'test' was also declared here.
node_modules/@types/mocha/index.d.ts:2770:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xit' must be of type 'It', but here has type 'PendingTestFunction'.
2770 declare var xit: Mocha.PendingTestFunction;
~~~
node_modules/@types/jest/index.d.ts:43:13
43 declare var xit: jest.It;
~~~
'xit' was also declared here.
Found 7 errors.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/badges.yml
.github/workflows/ci.yml
cypress-io/github-action v2
cycjimmy/semantic-release-action v2
package.json
debug 4.3.4
cypress 9.7.0
semantic-release 19.0.5
In index.ts
we use reference path
But after building the reference paths are gone
Thus EventEmitter
type is not found in the user project, see bahmutov/local-cypress-and-jest-typescript-example#7
I'm really just wrapping my head around how this all works, so apologies if this isn't actually possible.
My understanding is that local-cypress:
In our Angular project, we have lots and lots of e2e tests that work just fine with the global types.
We're just starting to get into component tests, and would like to put the side-by-side with the components themselves, so local-cypress
seems necessary to get around type conflicts with our Jasmine tests.
If local-cypress
provided a .d.ts
file with the global types it removed from Cypress, I believe I could reference that in my Cypress directory to allow the e2e tests to have global types, while using local types for the component tests.
Currently I'm working around doing exactly this by creating a .d.ts
file locally with all of the removed types, but it would be nice if that were done internally in local-cypress
, so that it can't get out of sync.
Thoughts? Maybe there's an easy way to do all of this and I'm making way too much work out of it?
The new Cypress types have a change that causes the imports from local-cypress
to become any
(or throw errors if skipLibCheck: false
). This is especially painful for any custom commands. Addressed in #67.
i updated to the last version of cypress
today and then i got lots of errors in VS code for my jest tests, because VS code thought I was using cypress
.
So I uninstalled local-cypress
and reinstalled it, then restarted VS code and all the errors went away. Is this a known issue?
Hi and thanks for this package, this is coming in handy.
Any way to declare types for custom commands and chai-subsets ?
Extending Cypress.Chainable and Cypress.Chainer interfaces the classic way in a .d.ts doesn't seem to work.
检测到 bahmutov/local-cypress 一共引入了331个开源组件,存在1个漏洞
漏洞标题:ansi-regex 安全漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2021-3807
漏洞描述:Ansi-Regex是用于匹配ANSI 转义码的正则表达式。
ansi-regex 存在安全漏洞,该漏洞源于易受低效正则表达式复杂性的影响。
影响范围:(2.1.1, 5.0.1)
最小修复版本:5.0.1
缺陷组件引入路径:[email protected]>[email protected]>[email protected]>[email protected]>[email protected]>[email protected]
[email protected]>[email protected]>[email protected]>[email protected]>[email protected]>[email protected]
[email protected]>[email protected]>[email protected]>[email protected]>[email protected]>[email protected]
[email protected]>[email protected]>[email protected]>[email protected]>[email protected]>[email protected]
另外还有几个漏洞,详细报告:https://mofeisec.com/jr?p=a743f6
Would be keen to use if https://testing-library.com/docs/cypress-testing-library/intro types would be available?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.