### Package Development Setup Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Instructions for setting up a local test server for package development, including installing dependencies and starting the Docker server. ```Bash cd ./test-server/ ``` ```Bash composer install yarn # or npm install ``` ```Bash docker-compose up ``` ```Bash yarn cypress:open ``` -------------------------------- ### Install cypress-mailhog Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Installs the cypress-mailhog package using npm, yarn, or pnpm. This is the first step to integrate MailHog commands into your Cypress tests. ```bash # npm npm install --save-dev cypress-mailhog # yarn yarn add --dev cypress-mailhog # pnpm pnpm add -D cypress-mailhog ``` -------------------------------- ### Configure MailHog Base URL Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Sets the base URL for your MailHog installation in the Cypress configuration file. This allows the package to connect to your MailHog instance. ```typescript import { defineConfig } from 'cypress'; export default defineConfig({ projectId: "****", env: { mailHogUrl: "http://localhost:8090/", }, }); ``` -------------------------------- ### Get First Mail Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Yields the first email from the currently loaded selection of emails. This is useful after fetching a list of emails. ```javascript cy .mhGetAllMails() .should('have.length', 1) .mhFirst(); ``` -------------------------------- ### Get All Mails Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Retrieves all emails from MailHog, with an optional limit. The command retries automatically until emails are found or the timeout is reached. ```javascript cy .mhGetAllMails() .should('have.length', 1); ``` -------------------------------- ### Get Mail Attachments Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Retrieves a list of all attachment file names for the current email. This is useful for verifying that the correct attachments are present. ```JavaScript cy .mhGetAllMails() .should('have.length', 1) .mhFirst() .mhGetAttachments() .should('have.length', 2) .should('include', 'sample.pdf'); ``` -------------------------------- ### Get Jim Mode Status Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Retrieves the current status of the Jim chaos monkey feature, indicating whether it is enabled or disabled. ```JavaScript cy .mhGetJimMode() .should('eq', true); ``` -------------------------------- ### Get Mail Recipients Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Retrieves the recipients of the current email. This command is typically chained after selecting a specific email, for example, using `mhFirst()`. ```JavaScript cy .mhGetAllMails() .should('have.length', 1) .mhFirst() .mhGetRecipients() .should('contain', 'recipient@example.com'); ``` -------------------------------- ### Get Mails by Subject Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Fetches emails from MailHog that match a specific subject. The command retries automatically until matching emails are found or the timeout is reached. ```javascript cy .mhGetMailsBySubject('My Subject') .should('have.length', 1); ``` -------------------------------- ### Get Mails by Recipient Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Fetches emails from MailHog that were sent to a specific recipient address. This command does not automatically retry. ```javascript cy .mhGetMailsByRecipient('recipient@example.com') .should('have.length', 1); ``` -------------------------------- ### Get Mail Subject Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Yields the subject of the currently selected email. This is typically used after selecting a single email using commands like 'mhFirst()'. ```javascript cy .mhGetAllMails() .should('have.length', 1) .mhFirst() .mhGetSubject() .should('eq', 'My Mails Subject'); ``` -------------------------------- ### Get Mails by Sender Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Fetches emails from MailHog that were sent by a specific sender address. The command retries automatically until matching emails are found or the timeout is reached. ```javascript cy .mhGetMailsBySender('sender@example.com') .should('have.length', 1); ``` -------------------------------- ### Get Mail Body Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Yields the body content of the currently selected email. Useful for verifying email content during automated tests. ```javascript cy .mhGetAllMails() .should('have.length', 1) .mhFirst() .mhGetBody() .should('contain', 'Part of the Message Body'); ``` -------------------------------- ### Get Mail Sender Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Yields the sender's email address of the currently selected email. This command helps in verifying the sender information of an email. ```javascript cy .mhGetAllMails() .should('have.length', 1) .mhFirst() .mhGetSender() .should('eq', 'sender@example.com'); ``` -------------------------------- ### MailHog and Test Server URLs Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Provides the URLs for accessing the test page, MailHog interface, and the Cypress test client. ```APIDOC Test Page: http://localhost:3000/cypress-mh-tests/ MailHog: http://localhost:8090/ ``` -------------------------------- ### Import cypress-mailhog Source: https://github.com/smenigat/cypress-mailhog/blob/master/README.md Imports the cypress-mailhog package into your Cypress support file, making its custom commands available for use in your tests. ```javascript // cypress/support/commands import 'cypress-mailhog'; ``` -------------------------------- ### Email Generation Buttons and Event Handling Source: https://github.com/smenigat/cypress-mailhog/blob/master/test-server/index.html This JavaScript code renders a set of buttons for generating different types of emails (single, with attachment, bulk). It also includes an event listener for button clicks, which triggers an AJAX POST request to 'mailer.php' to perform the email generation. The UI updates to show the status (pending, success, failure) and displays the debug output from the server. ```javascript var actions = [ { action: 'generate-single', label: 'Generate Single' }, { action: 'generate-single-with-attachment', label: 'Generate Single with Attachment' }, { action: 'generate-bulk', label: 'Generate Multiple' }, { action: 'generate-bulk-unique', label: 'Generate Unique Batch' }, ]; var $actions = $('.action-wrapper'); $.each(actions, function (index, action) { var $newButton = $('