feat: Add test infrastructure with Jest and Playwright for Chromium
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Example unit tests for the 3D Flight Simulator project
|
||||
*/
|
||||
|
||||
describe('Math utilities', () => {
|
||||
it('should add two numbers', () => {
|
||||
const result = 2 + 3;
|
||||
expect(result).toBe(5);
|
||||
});
|
||||
|
||||
it('should subtract two numbers', () => {
|
||||
const result = 5 - 2;
|
||||
expect(result).toBe(3);
|
||||
});
|
||||
|
||||
it('should multiply two numbers', () => {
|
||||
const result = 3 * 4;
|
||||
expect(result).toBe(12);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Jest setup file
|
||||
* This file runs before any tests are executed
|
||||
*/
|
||||
|
||||
// Add any global setup here
|
||||
// For example: mocking global objects, setting up test environment, etc.
|
||||
|
||||
// Example: Mock localStorage
|
||||
const localStorageMock = (() => {
|
||||
let store = {};
|
||||
return {
|
||||
getItem: (key) => store[key] || null,
|
||||
setItem: (key, value) => {
|
||||
store[key] = value.toString();
|
||||
},
|
||||
removeItem: (key) => {
|
||||
delete store[key];
|
||||
},
|
||||
clear: () => {
|
||||
store = {};
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
Object.defineProperty(window, 'localStorage', {
|
||||
value: localStorageMock,
|
||||
});
|
||||
|
||||
// Example: Mock sessionStorage
|
||||
const sessionStorageMock = (() => {
|
||||
let store = {};
|
||||
return {
|
||||
getItem: (key) => store[key] || null,
|
||||
setItem: (key, value) => {
|
||||
store[key] = value.toString();
|
||||
},
|
||||
removeItem: (key) => {
|
||||
delete store[key];
|
||||
},
|
||||
clear: () => {
|
||||
store = {};
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
Object.defineProperty(window, 'sessionStorage', {
|
||||
value: sessionStorageMock,
|
||||
});
|
||||
Reference in New Issue
Block a user