Managing servers with Cypress
Learn how to work with Mailosaur servers using Cypress.
The server object
{
"id": "{SERVER_ID}",
"password": "***",
"name": "Server name",
"users": [],
"messages": 16,
"retention": 14
}
Attribute | Description |
---|---|
id | The unique identifier for the server. |
password | The password for SMTP and POP3 access. |
name | The server’s name. |
users | An array of non-administrators who have access to this server. |
messages | The total count of all messages currently held by the server. |
retention | The number of days that messages will be retained before automatic deletion.. |
Listing servers
describe('Mailosaur Tests', () => {
it('Lists all the servers', () => {
cy.mailosaurListServers().then(result => {
expect(result.items).to.have.lengthOf(3)
})
})
})
The result
consists of the following structure:
{
"items": [ ... ]
}
Where items
is an array of Server objects.
Retrieving an individual server
describe('Mailosaur Tests', () => {
it('Retrieve a the server', () => {
cy.mailosaurGetServer('{SERVER_ID}').then(server => {
expect(server.name).to.equal('My server')
})
})
})
Creating a server
The only parameter you need to provide when creating a new server is name
:
describe('Mailosaur Tests', () => {
it('Create a new server', () => {
cy.mailosaurCreateServer({
name: 'My new server'
}).then(server => {
expect(server.name).to.equal('My new server')
})
})
})
Deleting a server
describe('Mailosaur Tests', () => {
it('Delete a server', () => {
cy.mailosaurDeleteServer('{SERVER_ID}')
})
})