-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: switch from create-react-app to vite
create-react-app is apparently deprecated, so the cool kids use vite, I guess. Not ready to merge for several major reasons: * tests fail. My attempt to support relative URLs from within `FixJSDomEnvironment.ts` doesn't appear to be working. * `npm run build` is failing. It seems to be stricter now about some things that were already wrong. * `npm run dev` seems to be just showing a blank page. I swear it was just working. Not sure what I changed since then. * I probably have some docs to update.
- Loading branch information
Showing
11 changed files
with
7,642 additions
and
26,113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// https://github.com/jsdom/jsdom/issues/1724#issuecomment-1446858041 | ||
|
||
import JSDOMEnvironment from "jest-environment-jsdom"; | ||
|
||
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string | ||
export default class FixJSDOMEnvironment extends JSDOMEnvironment { | ||
constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) { | ||
super(...args); | ||
|
||
// `src/api.ts` expects to be able to use fetch with relative URLs, which | ||
// node's native fetch does not like. Somehow this matters even though we're | ||
// using msw? | ||
this.global.fetch = ( | ||
resource: RequestInfo | URL, | ||
options?: RequestInit | ||
) => { | ||
return global.fetch( | ||
new URL(resource as string, "http://localhost"), | ||
options | ||
); | ||
}; | ||
this.global.Headers = Headers; | ||
this.global.Request = Request; | ||
this.global.Response = Response; | ||
|
||
// `src/LiveCamera/parser.ts` uses TextDecoder. | ||
this.global.TextDecoder = TextDecoder; | ||
} | ||
} |
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,36 @@ | ||
// This file is part of Moonfire NVR, a security camera network video recorder. | ||
// Copyright (C) 2023 The Moonfire NVR Authors; see AUTHORS and LICENSE.txt. | ||
// SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception | ||
|
||
import type { Config } from "jest"; | ||
|
||
const config: Config = { | ||
testEnvironment: "./FixJSDomEnvironment.ts", | ||
|
||
transform: { | ||
// https://github.com/swc-project/jest | ||
"\\.[tj]sx?$": [ | ||
"@swc/jest", | ||
{ | ||
// https://swc.rs/docs/configuration/compilation | ||
// https://github.com/swc-project/jest/issues/167#issuecomment-1809868077 | ||
jsc: { | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"], | ||
|
||
// https://github.com/jaredLunde/react-hook/issues/300#issuecomment-1845227937 | ||
moduleNameMapper: { | ||
"@react-hook/(.*)": "<rootDir>/node_modules/@react-hook/$1/dist/main", | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.