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

View file

@ -0,0 +1,32 @@
declare let window:any;
//this class is used to communicate with cypress, our e2e testing client
//Since cypress cannot manipulate canvas, we notified it with console logs
class CypressAsserter {
constructor() {
window.cypressAsserter = this
}
gameStarted() {
console.log('Started the game')
}
preloadStarted() {
console.log('Preloading')
}
preloadFinished() {
console.log('Preloading done')
}
initStarted() {
console.log('startInit')
}
initFinished() {
console.log('startInit done')
}
}
export const cypressAsserter = new CypressAsserter()

View file

@ -3,6 +3,7 @@ import {MessageUserPositionInterface} from "../../Connexion";
import {CurrentGamerInterface, GamerInterface, Player} from "../Player/Player";
import {DEBUG_MODE, RESOLUTION, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable";
import Tile = Phaser.Tilemaps.Tile;
import {cypressAsserter} from "../../Cypress/CypressAsserter";
export enum Textures {
Rock = 'rock',
@ -39,6 +40,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
//hook preload scene
preload(): void {
cypressAsserter.preloadStarted();
this.load.image(Textures.Tiles, 'maps/tiles.png');
this.load.tilemapTiledJSON(Textures.Map, 'maps/map2.json');
this.load.image(Textures.Rock, 'resources/objects/rockSprite.png');
@ -46,6 +48,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
'resources/characters/pipoya/Male 01-1.png',
{ frameWidth: 32, frameHeight: 32 }
);
cypressAsserter.preloadFinished();
}
//hook initialisation
@ -53,6 +56,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
//hook create scene
create(): void {
cypressAsserter.initStarted();
//initalise map
this.Map = this.add.tilemap("map");
@ -83,6 +87,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
//initialise camera
this.initCamera();
cypressAsserter.initFinished();
}
//todo: in a dedicated class/function?

View file

@ -2,6 +2,7 @@ import 'phaser';
import GameConfig = Phaser.Types.Core.GameConfig;
import {GameManager} from "./Phaser/Game/GameManager";
import {DEBUG_MODE, RESOLUTION} from "./Enum/EnvironmentVariable";
import {cypressAsserter} from "./Cypress/CypressAsserter";
let gameManager = new GameManager();
@ -20,6 +21,8 @@ const config: GameConfig = {
}
};
cypressAsserter.gameStarted();
gameManager.createGame().then(() => {
let game = new Phaser.Game(config);