Add tests to make sure our config validation error message doesn't regress
Sathya Gunasekaran committed
Nov 8, 2023 at 16:09 UTC
8b12f179d3350d6719b0dacc83d4153d9cc3da23
1 file changed
+29
compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts
new
+29
@@ -0,0 +1,29 @@
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+import { validateEnvironmentConfig } from "..";
9
+
10
+describe("parseConfigPragma()", () => {
11
+ it("passing null throws", () => {
12
+ expect(() => validateEnvironmentConfig(null as any)).toThrow();
13
+ });
14
+
15
+ // tests that the errror message remains useful
16
+ it("passing incorrect value throws", () => {
17
+ expect.assertions(1);
18
+
19
+ try {
20
+ validateEnvironmentConfig({
21
+ validateHooksUsage: 1,
22
+ } as any);
23
+ } catch (err) {
24
+ expect(err.message).toBe(
25
+ '[ReactForget] InvalidConfig: Validation error: Expected boolean, received number at "validateHooksUsage". Update Forget config to fix the error'
26
+ );
27
+ }
28
+ });
29
+});