mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[be] Flag and test for unexpected exceptions during compilations
This commit is contained in:
@@ -361,6 +361,15 @@ function* runWithEnvironment(
|
||||
const ast = codegenReactiveFunction(reactiveFunction).unwrap();
|
||||
yield log({ kind: "ast", name: "Codegen", value: ast });
|
||||
|
||||
/**
|
||||
* This flag should be only set for unit / fixture tests to check
|
||||
* that Forget correctly handles unexpected errors (e.g. exceptions
|
||||
* thrown by babel functions or other unexpected exceptions).
|
||||
*/
|
||||
if (env.config.throwUnknownException__testonly) {
|
||||
throw new Error("unexpected error");
|
||||
}
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,12 @@ const EnvironmentConfigSchema = z.object({
|
||||
* Intended for use in demo purposes (incl playground)
|
||||
*/
|
||||
enableMemoizationComments: z.boolean().default(false),
|
||||
|
||||
/**
|
||||
* [TESTING ONLY] Throw an unknown exception during compilation to
|
||||
* simulate unexpected exceptions e.g. errors from babel functions.
|
||||
*/
|
||||
throwUnknownException__testonly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export type EnvironmentConfig = z.infer<typeof EnvironmentConfigSchema>;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @throwUnknownException__testonly:true
|
||||
|
||||
function Component() {}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
unexpected error
|
||||
```
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// @throwUnknownException__testonly:true
|
||||
|
||||
function Component() {}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
};
|
||||
Reference in New Issue
Block a user