Import a function throws type error exception
See original GitHub issueCurrent behavior:
Importing a function from a diferent file throws a type error
Test code to reproduce
I want to test a page wich uses basic auth. So I write this line on a test:
cy.visit("/my_url", { auth:{
username: Cypress.env("BASICAUTH_USERNAME"),
password: Cypress.env("BASICAUTH_USERNAME")
} });
This line works with no problem. However, I want to test other pages with basic auth too. So, in order to avoid repeating this object I made a function to retrieve it:
//Auth.js"
export default {
basicAuth: () => {
return {
username: Cypress.env("BASICAUTH_USERNAME"),
password: Cypress.env("BASICAUTH_USERNAME")
};
}
};
Then I import it on my original test file:
import { basicAuth } from "./Auth";
//other lines here:
cy.visit("/my_url", { auth:basicAuth() });
Then when I run the code, I get a Type error on console:
> TypeError: Auth_1.basicAuth is not a function
at xxxxxxx (#URL-Here#/__cypress/tests?p=test/app.spec.js-193:74:26)
at Context.<anonymous> (#URL-Here#/__cypress/tests?p=test/app.spec.js-193:29:13)
Versions
Cypress/included:4.4.0 from https://github.com/cypress-io/cypress-docker-images
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Built-in Exceptions — Python 3.11.1 documentation
Except where mentioned, they have an “associated value” indicating the detailed cause of the error. This may be a string or a tuple...
Read more >How to declare a function that throws an error in Typescript
It's possible to specify error type only if a function returns an error, not throws it (this rarely happens and is prone to...
Read more >How to Throw Exceptions in Python - Rollbar
Python throws the TypeError exception when there are wrong data types. Similar to TypeError, there are several built-in exceptions like:.
Read more >throw - JavaScript - MDN Web Docs - Mozilla
The throw statement throws a user-defined exception. ... If no catch block exists among caller functions, the program will terminate.
Read more >How to throw an exception - Python Morsels
The sqrt function in Python's math module raises an exception when it's given a negative ... and we'll raise a TypeError exception if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll check it out.
Released in
4.4.1
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v4.4.1, please open a new issue.