implemented basic e2e testing

This commit is contained in:
kharhamel 2020-04-14 20:04:55 +02:00
parent 705617abe7
commit a2ed7164e4
11 changed files with 1540 additions and 0 deletions

3
e2e/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
screenshots/
videos/
node_modules/

28
e2e/CYPRESS.md Normal file
View file

@ -0,0 +1,28 @@
# Testing with cypress
This project use [cypress](https://www.cypress.io/) to do functional testing of the website.
Unfortunately we cannot integrate it with docker-compose for the moment, so you will need to install some packages locally on your pc.
You will need to install theses dependancies on linux (don't know about mac):
```bash
sudo apt update
sudo apt install libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
```
Cypress can be installed locally in the e2e directory
```bash
cd e2e
npm install
```
How to use:
```bash
npm run cy:run
npm run cy:open
```
The first command will run all tests in the terminal, while the second will open the interactive task runner which allow you to easily manage the test workflow
[More details here](https://docs.cypress.io/guides/getting-started/testing-your-app.html#Step-1-Start-your-server)

6
e2e/cypress.json Normal file
View file

@ -0,0 +1,6 @@
{
"baseUrl": "http://workadventure.localhost",
"video": false,
"pluginsFile": false,
"supportFile": false
}

View file

@ -0,0 +1,25 @@
Cypress.on('window:before:load', (win) => {
// because this is called before any scripts
// have loaded - the ga function is undefined
// so we need to create it.
win.cypressAsserter = cy.stub().as('ca')
})
describe('WorkAdventureGame', () => {
beforeEach(() => {
cy.visit('/', {
onBeforeLoad (win) {
cy.spy(win.console, 'log').as('console.log')
},
})
});
it('loads', () => {
cy.get('@console.log').should('be.calledWith', 'Started the game')
cy.get('@console.log').should('be.calledWith', 'Preloading')
cy.get('@console.log').should('be.calledWith', 'Preloading done')
cy.get('@console.log').should('be.calledWith', 'startInit')
cy.get('@console.log').should('be.calledWith', 'startInit done')
});
});

1406
e2e/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

9
e2e/package.json Normal file
View file

@ -0,0 +1,9 @@
{
"dependencies": {
"cypress": "^3.8.3"
},
"scripts": {
"cy:run": "cypress run",
"cy:open": "cypress open"
}
}