-
Notifications
You must be signed in to change notification settings - Fork 143
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. Working on mergeability...
- Loading branch information
Showing
17 changed files
with
7,508 additions
and
25,832 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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
/coverage | ||
|
||
# production | ||
/build | ||
/dist | ||
|
||
# misc | ||
.DS_Store | ||
|
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,38 @@ | ||
// 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 | ||
|
||
// Environment based on `jsdom` with some extra globals, inspired by | ||
// the following comment: | ||
// 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); | ||
|
||
// Tests use fetch calls with relative URLs + msw to intercept. | ||
this.global.fetch = ( | ||
resource: RequestInfo | URL, | ||
options?: RequestInit | ||
) => { | ||
throw "must use msw to fetch: " + resource; | ||
}; | ||
|
||
class MyRequest extends Request { | ||
constructor(input: RequestInfo | URL, init?: RequestInit | undefined) { | ||
input = new URL(input as string, "http://localhost"); | ||
super(input, init); | ||
} | ||
} | ||
|
||
this.global.Headers = Headers; | ||
this.global.Request = MyRequest; | ||
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.