Update jest to v29.5.0
This updates jest to the latest version (29.5.0) and fixes everything that the upgrade breaks. One of the biggest differences is that the mock types changed and I'm once again confused as to the "proper" way to create mocks in jest. Whatever.
This commit is contained in:
parent
c52f03a7e1
commit
dd432b505b
|
@ -4,6 +4,10 @@ module.exports = {
|
|||
'^test/(.*)': '<rootDir>/test/$1',
|
||||
'\\.css$': 'identity-obj-proxy',
|
||||
'\\.scss$': 'identity-obj-proxy',
|
||||
// For some reason the preact modules are not where they are
|
||||
// expected. This seems to have something to do with jest > v27.
|
||||
// https://github.com/preactjs/enzyme-adapter-preact-pure/issues/179#issuecomment-1201096897
|
||||
'^preact(/(.*)|$)': 'preact$1',
|
||||
},
|
||||
'roots': [
|
||||
'js/',
|
||||
|
@ -17,6 +21,9 @@ module.exports = {
|
|||
'^.+\\.ts$': 'ts-jest',
|
||||
'^.*\\.tsx$': 'ts-jest',
|
||||
},
|
||||
'transformIgnorePatterns': [
|
||||
'/node_modules/(?!(@testing-library/preact/dist/esm)/)',
|
||||
],
|
||||
'setupFilesAfterEnv': [
|
||||
'<rootDir>/test/jest-setup.ts'
|
||||
],
|
||||
|
@ -24,5 +31,6 @@ module.exports = {
|
|||
'/node_modules/',
|
||||
'/js/roms/',
|
||||
'/test/',
|
||||
]
|
||||
],
|
||||
'preset': 'ts-jest',
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,14 +32,14 @@
|
|||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/preact": "^3.0.1",
|
||||
"@testing-library/user-event": "^13.1.3",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/jest-image-snapshot": "^4.3.1",
|
||||
"@types/micromodal": "^0.3.2",
|
||||
"@types/wicg-file-system-access": "^2020.9.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||
"@typescript-eslint/parser": "^5.27.0",
|
||||
"ajv": "^6.12.0",
|
||||
"babel-jest": "^27.2.4",
|
||||
"babel-jest": "^29.5.0",
|
||||
"canvas": "^2.8.0",
|
||||
"css-loader": "^6.7.1",
|
||||
"eslint": "^8.17.0",
|
||||
|
@ -48,7 +48,8 @@
|
|||
"eslint-plugin-react-hooks": "^4.5.0",
|
||||
"file-loader": "^6.0.0",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "^27.2.4",
|
||||
"jest": "^29.5.0",
|
||||
"jest-environment-jsdom": "^29.5.0",
|
||||
"jest-image-snapshot": "^4.5.1",
|
||||
"node-forge": "^1.3.0",
|
||||
"raw-loader": "^4.0.0",
|
||||
|
@ -61,7 +62,7 @@
|
|||
"stylelint-config-standard": "^33.0.0",
|
||||
"stylelint-config-standard-scss": "^9.0.0",
|
||||
"stylelint-scss": "^4.6.0",
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-jest": "^29.1.0",
|
||||
"ts-loader": "^9.3.0",
|
||||
"typescript": "^4.7.3",
|
||||
"webpack": "^5.76.0",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* setup. It still requires typing.
|
||||
*/
|
||||
|
||||
const JsdomEnvironment = require('jest-environment-jsdom');
|
||||
import JsdomEnvironment from 'jest-environment-jsdom';
|
||||
|
||||
export default class JsdomEnvironmentWithBackDoors extends JsdomEnvironment {
|
||||
async setup() {
|
||||
|
|
|
@ -8,7 +8,6 @@ import { DriveNumber, NibbleDisk, WozDisk } from 'js/formats/types';
|
|||
import { byte } from 'js/types';
|
||||
import { toHex } from 'js/util';
|
||||
import { VideoModes } from 'js/videomodes';
|
||||
import { mocked } from 'ts-jest/utils';
|
||||
import { BYTES_BY_SECTOR_IMAGE, BYTES_BY_TRACK_IMAGE } from '../formats/testdata/16sector';
|
||||
|
||||
jest.mock('js/apple2io');
|
||||
|
@ -34,7 +33,7 @@ function setWriteProtected(diskII: DiskII, isWriteProtected: boolean) {
|
|||
|
||||
describe('DiskII', () => {
|
||||
const mockApple2IO = new Apple2IO({} as unknown as CPU6502, {} as unknown as VideoModes);
|
||||
const callbacks: Callbacks = {
|
||||
const callbacks: jest.Mocked<Callbacks> = {
|
||||
driveLight: jest.fn(),
|
||||
dirty: jest.fn(),
|
||||
label: jest.fn(),
|
||||
|
@ -66,7 +65,7 @@ describe('DiskII', () => {
|
|||
|
||||
const state = diskII.getState();
|
||||
// These are just arbitrary changes, not an exhaustive list of fields.
|
||||
(state.drives[1].driver as {skip:number}).skip = 1;
|
||||
(state.drives[1].driver as { skip: number }).skip = 1;
|
||||
state.controllerState.driveNo = 2;
|
||||
state.controllerState.latch = 0x42;
|
||||
state.controllerState.on = true;
|
||||
|
@ -115,7 +114,7 @@ describe('DiskII', () => {
|
|||
jest.useFakeTimers();
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.ioSwitch(0x89); // turn on the motor
|
||||
mocked(callbacks.driveLight).mockReset();
|
||||
callbacks.driveLight.mockReset();
|
||||
|
||||
diskII.ioSwitch(0x88); // turn off the motor
|
||||
|
||||
|
@ -140,7 +139,7 @@ describe('DiskII', () => {
|
|||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.ioSwitch(0x8B); // select drive 2
|
||||
diskII.ioSwitch(0x89); // turn on the motor
|
||||
mocked(callbacks.driveLight).mockReset();
|
||||
callbacks.driveLight.mockReset();
|
||||
|
||||
diskII.ioSwitch(0x88); // turn off the motor
|
||||
|
||||
|
@ -479,7 +478,7 @@ describe('DiskII', () => {
|
|||
it('writes a nibble to the disk', () => {
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'BYTES_BY_TRACK', 'po', BYTES_BY_TRACK_IMAGE);
|
||||
let disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
let disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
let track0 = disk1.tracks[0];
|
||||
expect(track0[0]).toBe(0xFF);
|
||||
|
||||
|
@ -487,7 +486,7 @@ describe('DiskII', () => {
|
|||
diskII.ioSwitch(0x8F, 0x80); // write
|
||||
diskII.ioSwitch(0x8C); // shift
|
||||
|
||||
disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
track0 = disk1.tracks[0];
|
||||
expect(track0[0]).toBe(0x80);
|
||||
});
|
||||
|
@ -495,7 +494,7 @@ describe('DiskII', () => {
|
|||
it('writes two nibbles to the disk', () => {
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'BYTES_BY_TRACK', 'po', BYTES_BY_TRACK_IMAGE);
|
||||
let disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
let disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
let track0 = disk1.tracks[0];
|
||||
expect(track0[0]).toBe(0xFF);
|
||||
|
||||
|
@ -505,7 +504,7 @@ describe('DiskII', () => {
|
|||
diskII.ioSwitch(0x8F, 0x81); // write
|
||||
diskII.ioSwitch(0x8C); // shift
|
||||
|
||||
disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
disk1 = diskII.getState().drives[1].disk as NibbleDisk;
|
||||
track0 = disk1.tracks[0];
|
||||
expect(track0[0]).toBe(0x80);
|
||||
expect(track0[1]).toBe(0x81);
|
||||
|
@ -571,7 +570,7 @@ describe('DiskII', () => {
|
|||
|
||||
it('spins the disk when motor is on', () => {
|
||||
let cycles: number = 0;
|
||||
mocked(mockApple2IO).cycles.mockImplementation(() => cycles);
|
||||
(mockApple2IO.cycles as jest.Mock).mockImplementation(() => cycles);
|
||||
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'DOS 3.3 System Master', 'woz', DOS33_SYSTEM_MASTER_IMAGE);
|
||||
|
@ -589,7 +588,7 @@ describe('DiskII', () => {
|
|||
|
||||
it('does not spin the disk when motor is off', () => {
|
||||
let cycles: number = 0;
|
||||
mocked(mockApple2IO).cycles.mockImplementation(() => cycles);
|
||||
(mockApple2IO.cycles as jest.Mock).mockImplementation(() => cycles);
|
||||
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'DOS 3.3 System Master', 'woz', DOS33_SYSTEM_MASTER_IMAGE);
|
||||
|
@ -606,7 +605,7 @@ describe('DiskII', () => {
|
|||
|
||||
it('reads an FF sync byte from the beginning of the image', () => {
|
||||
let cycles: number = 0;
|
||||
mocked(mockApple2IO).cycles.mockImplementation(() => cycles);
|
||||
(mockApple2IO.cycles as jest.Mock).mockImplementation(() => cycles);
|
||||
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'DOS 3.3 System Master', 'woz', DOS33_SYSTEM_MASTER_IMAGE);
|
||||
|
@ -632,7 +631,7 @@ describe('DiskII', () => {
|
|||
|
||||
it('reads several FF sync bytes', () => {
|
||||
let cycles: number = 0;
|
||||
mocked(mockApple2IO).cycles.mockImplementation(() => cycles);
|
||||
(mockApple2IO.cycles as jest.Mock).mockImplementation(() => cycles);
|
||||
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'DOS 3.3 System Master', 'woz', DOS33_SYSTEM_MASTER_IMAGE);
|
||||
|
@ -665,7 +664,7 @@ describe('DiskII', () => {
|
|||
|
||||
it('reads random garbage on uninitialized tracks', () => {
|
||||
let cycles: number = 0;
|
||||
mocked(mockApple2IO).cycles.mockImplementation(() => cycles);
|
||||
(mockApple2IO.cycles as jest.Mock).mockImplementation(() => cycles);
|
||||
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'DOS 3.3 System Master', 'woz', DOS33_SYSTEM_MASTER_IMAGE);
|
||||
|
@ -761,7 +760,7 @@ class TestDiskReader {
|
|||
diskII: DiskII;
|
||||
|
||||
constructor(driveNo: DriveNumber, label: string, image: ArrayBufferLike, apple2IO: Apple2IO, callbacks: Callbacks) {
|
||||
mocked(apple2IO).cycles.mockImplementation(() => this.cycles);
|
||||
(apple2IO.cycles as jest.Mock).mockImplementation(() => this.cycles);
|
||||
|
||||
this.diskII = new DiskII(apple2IO, callbacks);
|
||||
this.diskII.setBinary(driveNo, label, 'woz', image);
|
||||
|
|
Loading…
Reference in New Issue