mailslurp / cypress-mailslurp Goto Github PK
View Code? Open in Web Editor NEWOfficial MailSlurp plugin for CypressJS
License: MIT License
Official MailSlurp plugin for CypressJS
License: MIT License
Encountering a SyntaxError when using cy.mailslurp() in a Cypress before() hook. The error suggests an unexpected token '<', indicating invalid JSON. This prevents the execution of subsequent tests. Assistance needed to resolve this issue promptly.
I have set up everything which is there in documenation, Below is the step which I have done in my project.
Version: "cypress-mailslurp": "^1.5.0"
cypress.config.ts
defaultCommandTimeout: 30000,
responseTimeout: 30000,
requestTimeout: 30000,
env: {
MAILSLURP_API_KEY: 'API_KEY'
},
cypress/support/commands.ts
/// <reference types="cypress-mailslurp" />
import { MailSlurp } from 'mailslurp-client';
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
mailslurp: () => Promise<MailSlurp>;
}
}
}
cypress/support/e2e.ts
import 'cypress-mailslurp';
import '@cypress/support/command.ts';
cypress/e2e/authentication/authenticationActions.cy.ts
before(() => {
cy.visit('/')
cy.once('uncaught:exception', () => false);
cy.log('Wrap inbox before test');
return cy.mailslurp()
.then(mailslurp => mailslurp.createInbox())
.then(inbox => {
cy.log(`Inbox id ${inbox.id}`)
// save inbox id and email address to this (make sure you use function and not arrow syntax)
cy.wrap(inbox.id).as('inboxId')
cy.wrap(inbox.emailAddress).as('emailAddress')
email = inbox.emailAddress;
})
})
Though, i am getting same error, mailslurp is not function. can someone please help me with this?
Currently we have to set the default timeouts in cypress config to exorbitantly high values which affects all assertions in the test suite - not just the email-related assertions.
i.e.
// cypress.config.ts
export default defineConfig({
defaultCommandTimeout: 60000,
responseTimeout: 60000,
requestTimeout: 60000,
...
Cypress typically allows consumers to set timeouts on .then chains w/ an options object.
i.e.
cy.get('something').then(
{ timeout: 60000 }, // first arg can be an options object instead of the callback
() => {
// make assertions
}
)
It'd be beneficial if this library could allow for the same one-off setting of timeouts so default timeouts of the test suite don't need to be set for the sole purpose of mailslurp assertions.
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.