-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kevinramharak/feature/add-tests-vitest
Add testing setup
- Loading branch information
Showing
6 changed files
with
2,557 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { describe, it, expect, vi } from 'vitest' | ||
import { mount } from '@vue/test-utils' | ||
import Game from '../Game.vue' | ||
|
||
describe('Game', () => { | ||
/** | ||
* @type {import('phaser').Types.Core.GameConfig} | ||
*/ | ||
const config = { | ||
/** | ||
* Prevent the Phaser & Phavuer banner from polluting the test logs | ||
*/ | ||
banner: false, | ||
}; | ||
|
||
it('emits the create event', () => { | ||
const wrapper = mount(Game, { | ||
props: { | ||
config, | ||
}, | ||
}) | ||
expect(wrapper.emitted().create).toBeTruthy() | ||
}) | ||
|
||
it('appends a canvas element to the [data-phavuer-canvas]', () => { | ||
const wrapper = mount(Game, { | ||
props: { | ||
config, | ||
}, | ||
}) | ||
expect(wrapper.find('[data-phavuer-canvas] > canvas').exists()).toBe(true) | ||
}) | ||
|
||
it('emits the ready event', async () => { | ||
vi.useFakeTimers(); | ||
const wrapper = mount(Game, { | ||
props: { | ||
config, | ||
}, | ||
}) | ||
await vi.runOnlyPendingTimersAsync() | ||
expect(wrapper.emitted().ready).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
export default defineConfig({ | ||
plugins: [vue()], | ||
test: { | ||
browser: { | ||
/** | ||
* `name` is required | ||
*/ | ||
name: 'chrome', | ||
enabled: true, | ||
providerOptions: { | ||
logLevel: 'silent', logLevels: { webdriver: 'silent' } | ||
}, | ||
}, | ||
setupFiles: [ | ||
'./vitest.setup.mjs', | ||
], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'phaser' |
Oops, something went wrong.