Repository: dubzzz/fast-check
Pull request #903 (2020-08-19 06:48:29)

👷 Break CI whenever documentation compiles with warnings
<!-- Why is this PR for? -->
<!-- Describe the reason why you opened this PR or give a link towards the associated issue. -->

## In a nutshell

❌ New feature
❌ Fix an issue
❌ Documentation improvement
✔️ Other: *ci*

(✔️: yes, ❌: no)

## Potential impacts

None

codesandbox[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/dubzzz/fast-check/pr/903/builds/47259) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 994406219aecbe7581f845c002f5ac51a275ce00:

|Sandbox| Source |
|--|--|
|[Vanilla](https://codesandbox.io/s/vanilla-uz0cm)| Configuration |
|[dubzzz/fast-check: example](https://codesandbox.io/s/dubzzzfast-check-example-gpp1q)| Configuration |

coveralls: 
[![Coverage Status](https://coveralls.io/builds/32851051/badge)](https://coveralls.io/builds/32851051)

Coverage remained the same at 95.913% when pulling **994406219aecbe7581f845c002f5ac51a275ce00 on break-tests-if-warnings-in-docs** into **2d93f1279e25492eb2299d0a8b5ca54e1b6e6d0a on master**.


Patch:
diff --git a/api-extractor.json b/api-extractor.json
index 41ff0fa8..d420d37a 100644
--- a/api-extractor.json
+++ b/api-extractor.json
@@ -16,5 +16,17 @@
   },
   "apiReport": {
     "enabled": false
+  },
+  "messages": {
+    "compilerMessageReporting": {
+      "default": {
+        "logLevel": "error"
+      }
+    },
+    "extractorMessageReporting": {
+      "default": {
+        "logLevel": "error"
+      }
+    }
   }
 }
\ No newline at end of file
diff --git a/package.json b/package.json
index 00937f29..7df5a8be 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
     "e2e:watch": "jest --config jest.e2e.config.cjs --watch",
     "test:rollup-esm": "rollup --config test/rollup/esm/rollup.config.js && node test/rollup/esm/dist/main.js",
     "coverage": "cat ./coverage/lcov.info | coveralls",
-    "docs": "mkdirp docs/2-API && docsify-init --editDir documentation && cp -R documentation/* docs/ && api-extractor run --local && generate-ts-docs markdown -i docs/2-API -o docs/2-API && cat README.md | sed 's/https:\\/\\/github.com\\/dubzzz\\/fast-check\\/blob\\/master\\/documentation//g' > docs/README.md && markdownbars -i docs/_sidebar.md -o docs/_sidebar.md",
+    "docs": "mkdirp docs/2-API && docsify-init --editDir documentation && cp -R documentation/* docs/ && api-extractor run && generate-ts-docs markdown -i docs/2-API -o docs/2-API && cat README.md | sed 's/https:\\/\\/github.com\\/dubzzz\\/fast-check\\/blob\\/master\\/documentation//g' > docs/README.md && markdownbars -i docs/_sidebar.md -o docs/_sidebar.md",
     "docs:serve": "npx serve docs/",
     "format": "prettier --write \"**/*.{js,ts}\"",
     "format:check": "prettier --list-different \"**/*.{js,ts}\"",
diff --git a/src/check/runner/Runner.ts b/src/check/runner/Runner.ts
index 44bf3422..d94b0fa1 100644
--- a/src/check/runner/Runner.ts
+++ b/src/check/runner/Runner.ts
@@ -121,7 +121,7 @@ function check<Ts>(rawProperty: IRawProperty<Ts>, params?: Parameters<Ts>) {
   });
   if (qParams.reporter !== null && qParams.asyncReporter !== null)
     throw new Error('Invalid parameters encountered, reporter and asyncReporter cannot be specified together');
-  if (qParams.asyncReporter !== null && rawProperty.isAsync())
+  if (qParams.asyncReporter !== null && !rawProperty.isAsync())
     throw new Error('Invalid parameters encountered, only asyncProperty can be used when asyncReporter specified');
   const property = decorateProperty(rawProperty, qParams);
   const generator = toss(property, qParams.seed, qParams.randomType, qParams.examples);


Test patch:
diff --git a/test/unit/check/runner/Runner.spec.ts b/test/unit/check/runner/Runner.spec.ts
index 311467cd..7a1b355c 100644
--- a/test/unit/check/runner/Runner.spec.ts
+++ b/test/unit/check/runner/Runner.spec.ts
@@ -22,6 +22,50 @@ describe('Runner', () => {
     it('Should throw if property is an Arbitrary', () => {
       expect(() => check((char() as any) as IRawProperty<unknown>)).toThrowError();
     });
+    it.each`
+      isAsync
+      ${false}
+      ${true}
+    `('Should throw if both reporter and asyncReporter are defined (isAsync: $isAsync)', ({ isAsync }) => {
+      const p: IRawProperty<[number]> = {
+        isAsync: () => isAsync,
+        generate: () => new Shrinkable([0]),
+        run: () => null,
+      };
+      expect(() => check(p, { reporter: () => {}, asyncReporter: async () => {} })).toThrowError();
+    });
+    it('Should not throw if reporter is specified on synchronous properties', () => {
+      const p: IRawProperty<[number]> = {
+        isAsync: () => false,
+        generate: () => new Shrinkable([0]),
+        run: () => null,
+      };
+      expect(() => check(p, { reporter: () => {} })).not.toThrowError();
+    });
+    it('Should not throw if reporter is specified on asynchronous properties', () => {
+      const p: IRawProperty<[number]> = {
+        isAsync: () => true,
+        generate: () => new Shrinkable([0]),
+        run: () => null,
+      };
+      expect(() => check(p, { reporter: () => {} })).not.toThrowError();
+    });
+    it('Should throw if asyncReporter is specified on synchronous properties', () => {
+      const p: IRawProperty<[number]> = {
+        isAsync: () => false,
+        generate: () => new Shrinkable([0]),
+        run: () => null,
+      };
+      expect(() => check(p, { asyncReporter: async () => {} })).toThrowError();
+    });
+    it('Should not throw if asyncReporter is specified on asynchronous properties', () => {
+      const p: IRawProperty<[number]> = {
+        isAsync: () => true,
+        generate: () => new Shrinkable([0]),
+        run: () => null,
+      };
+      expect(() => check(p, { asyncReporter: async () => {} })).not.toThrowError();
+    });
     it('Should call the property 100 times by default (on success)', () => {
       let numCallsGenerate = 0;
       let numCallsRun = 0;