So I have eslint rules (for typescript project) for whole project, which I can't change - I'm extending them to e2e folder with Cypress (and here I override them if needed), also with plugin:cypress/recommended eslint rules. But now I'm struggling with errors in assertions. For example I have:
cy.get("button")
.should((button) => {
expect(button).to.be.enabled;
})
.click();
And on assertion I get Expected an assignment or function call and instead saw an expression.eslint#typescript-eslint/no-unused-expressions. I don't want to disable this rule for each line, or for whole project, because somewhere else I can forget/or something to do unused expression. How to resolve this only for assertions in Cypress? In eslint config where I have extension should I add something only for that?
Related
I need a solution. I have a lot of spec files with tests and after each of them I use cy.logout command.
I want to avoid write this logout function each time and want it global.
But when I tried add this function in index.js file it was called at the beginning of each test because index.js works perfect only with beforeEach but not with afterEach.
What should I do?
Thanks
[EDIT]
I just find out that problem was provoke by my mistake in code in second test, so the only problem I have with Cypress is that I dont get any information where I made my mistake because Cypress show me that problem is afterEach hook and nothing else.
If you want your logout runs only once for each of your spec file, and not after each of your test within the file, you must use after instead of afterEach.
after(() => {
cy.logout()
})
Using afterEach() or beforeEach() block in support/index.js. Refer below page to run a "global" hook
https://filiphric.com/cypress-basics-before-beforeeach-after-aftereach
We are in a process of migrating existing Protractor scripts(with Jasmine Framework) to Cypress.
I would like to know if we can use the Jasmine in Cypress also. As, Cypress by default uses Mocha.., so need a clarification if we can install Jasmine dependences along with Cypress to define the tests with Framework.
I don't think so. Cypress modifies/patches the Mocha hooks like beforeEach() and also the chai expect() to work with their framework.
Is there anything about Jasmine that you don't get out of the box with Cypress? I believe the expect() syntax may be different, if you have too many Jasmine-style expectations to change you may be able to add custom Chai expressions so that they work without modification.
I've a project on Webpack that I'm trying to setup SASS transpiling with. I believe I am fairly close, although there are issues with my configuration (code and details in the gist here).
Running webpack with the code as it is yields the following error:
/foobar/src/js/components/App.jsx
6:8 error Unable to resolve path to module '../../scss/components/app' import/no-unresolved
Having spent a while on this, I noted that if I replace the import 'scss/components/app' line in App.jsx with import '../../scss/components/app.scss', the transpilation works. This leads me to believe that there are two issues:
My resolve.root Webpack configuration isn't working since relative imports work, but not absolute ones.
My resolve.extensions Webpack configuration isn't being applied either, since I need to append the .scss file extension to get it working.
Other notes:
I'm using webpack 1.13.1.
If I intentionally introduce syntax errors into the SCSS file, webpack correctly prompts me of issues with that file.
I've also tried setting my resolve.root configuration as an array (i.e. [path.resolve(__dirname, './src')]) to no avail.
Goal-wise, I'm hoping to achieve something similar to this example.
I've tried debugging the import paths with console-loader and am getting undefined.
Any help will be appreciated, thanks!
UPDATE:
A friend just shared that the issue is coming not from sass-loader/etc., but from eslint. This means the nature of this question is going to be quite different (less webpack, more eslint).
Anyway, my .eslintrc extends that of AirBNB's, I'm guessing I need to modify it based on the details in this plugin.
The part of interest is:
settings:
import/ignore:
- node_modules # mostly CommonJS (ignored by default)
- \.coffee$ # fraught with parse errors
- \.(scss|less|css)$ # can't parse unprocessed CSS modules, either
I've updated my .eslintrc to resemble:
{
"extends": "airbnb",
"settings": {
"import/ignore": [".scss$"]
}
}
But am still getting errors. Any ideas?
Can you post all the files in the gist? I tried looking for issues just by looking at the code but a runnable example with all files and imports in webpack config would be more helpful.
I'm curious why you added eslint to loaders instead of preloaders. You need to add it to preloaders.
No where in the documentation does it tell you which scripts to include in which order. I would like to print to the console because I am running jasmine inside PhantomJS. What files should I use for this?
I'm trying:
bootstrap.js
console.js
jasmine.js
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter(console.log));
but it gives
TypeError: 'undefined' is not a constructor (evaluating 'new jasmine.ConsoleReporter(console.log)')
jasmine.js needs to come before console.js, as console.js adds ConsoleReporter() as a method to the jasmine object.
Look at the included sample btml runner. I found that any add on must load after boot.js. For example, Jasmine-jquery and teamcity reporters. These usually attach themselves to the global Jasmine object which is configured in boot.
I have a package that validates if the process has specific environment variables set on init(), else it panics.
I do this to ensure the process is properly configured at launch.
The problem is that this approach is not really testable (using _test.go files), since the environment doesn't exist in the test suite.
What's the best way to solve this problem?
Do you want to be able to test the validation, or just skip it entirely in the test file? Either way is going to use the same basic approach, which is to separate out the validation code into its own file that doesn't build during tests. If you just want to skip validation entirely during the test, put the whole init() function into that file. If you want to test validation, just make the validation code call your own shim to get environment values, and put your shim in that non-test file, and put a separate shim into a file that only compiles during tests.
You can control whether the file builds during tests using a build constraint in the file header. IIRC, running the tests applies the test constraint, so you can check for that.