@teambit/tester 1.0.184 → 1.0.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.defender/tester@1.0.184" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.defender/tester@1.0.186" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.defender/tester-preview"]=t():e["teambit.defender/tester-preview"]=t()}(self,(()=>(()=>{"use strict";var e={53300:(e,t,n)=>{Object.defineProperty(t,"Ay",{enumerable:!0,get:function(){return r.default}});var r=o(n(91204));function o(e){return e&&e.__esModule?e:{default:e}}o.__bit_component={id:"teambit.defender/content/tester-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/tester-overview",exported:!0}},91204:(e,t,n)=>{var r={id:"teambit.defender/content/tester-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/tester-overview",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=u,s(n(41594));var o=n(5016),i=n(65682),a=["components"];function s(e){return e&&e.__esModule?e:{default:e}}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}function d(e,t){if(null==e)return{};var n,r,o=l(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function l(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}s.__bit_component=r,p.__bit_component=r,d.__bit_component=r,l.__bit_component=r;var m={},c="wrapper";function u(e){var t=e.components,n=d(e,a);return(0,o.mdx)(c,p({},m,n,{components:t,mdxType:"MDXLayout"}),(0,o.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"},(0,o.mdx)("h1",null,"Tester Overview"),(0,o.mdx)("p",null,"The ",(0,o.mdx)("em",{parentName:"p"},"Tester")," provides a unified interface for testing components regardless of the specific tester they use."),(0,o.mdx)("p",null,"Software testing is a way to validate that an application or a module of it, behaves as expected."),(0,o.mdx)("p",null,"Web applications and services are often tested using a set of testing tools, where each tool plays a different role. For example, ",(0,o.mdx)("a",{parentName:"p",href:"https://jestjs.io/"},"Jest")," can be used as a test runner and as an assertion library, while ",(0,o.mdx)("a",{parentName:"p",href:"https://testing-library.com/"},"React Testing Library")," can be used for testing utilities."),(0,o.mdx)("p",null,"The Tester aspect is responsible for standardizing test execution for components; That is, it standardizes the way test runners are used. Other testing libraries used for utils, mocks, etc., are irrelevant, in that sense."),(0,o.mdx)("p",null,"Standardization is done for component testing during development (in the workspace) as well as for distribution (in a capsule ",", as part of the component ",(0,o.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"build pipeline"),")."),(0,o.mdx)("h2",null,"Testing in development"),(0,o.mdx)("p",null,"Bit tests all components in the ",(0,o.mdx)("a",{parentName:"p",href:"/workspace/overview"},"Workspace")," using just a single command. That is true for components of all types, regardless of their specific ",(0,o.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env"),", and as a consequence of that, their specific ",(0,o.mdx)("a",{parentName:"p",href:"/tester/overview"},"Tester implementation")," and configuration."),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit test\n")),(0,o.mdx)("p",null,"Components can be watched for changes and retested with a single command, as well."),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit test -w\n")),(0,o.mdx)("p",null,"To learn more on testing during development, please refer to ",(0,o.mdx)("a",{parentName:"p",href:"/tester/workspace-testing"},"Workspace Testing"),"."),(0,o.mdx)("h2",null,"Testing during build"),(0,o.mdx)("p",null,"Testing components for distribution is done during ",(0,o.mdx)("inlineCode",{parentName:"p"},"build")," by the Bit ",(0,o.mdx)("a",{parentName:"p",href:"/builder/overview"},"Builder"),"."),(0,o.mdx)("p",null,"Component build can be simulated with ",(0,o.mdx)("inlineCode",{parentName:"p"},"bit build")," and done through ",(0,o.mdx)("a",{parentName:"p",href:"/components/tags"},"Tag")," or ",(0,o.mdx)("a",{parentName:"p",href:"/components/snaps"},"Snap")),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit build\n")),(0,o.mdx)("p",null,"By default, Bit's pre-configured Envs includes a ",(0,o.mdx)("a",{parentName:"p",href:"/builder/overview#build-task"},"Build Task")," for testing components in the ",(0,o.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),", each using the Env's specific test configs."),(0,o.mdx)("p",null,"Testing during build provides the highest \"external validity\" by running tests on the distributable code that was generated by the Env's compiler and not by the tester's.\nThat way, the exact same code that will be consumed by other components, is tested before it is released. Moreover, since each component is tested in a capsule ",", isolated from the rest of the workspace, tests are guaranteed to provide results that are context-agnostic and free of false-positives."),(0,o.mdx)("h2",null,"Configuring and implementing Testers"),(0,o.mdx)("p",null,"Testers are configured in the ",(0,o.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env")," which is configured on your ",(0,o.mdx)("a",{parentName:"p",href:"/components/overview"},"Component"),". Customizing the Tester can be done by ",(0,o.mdx)("a",{parentName:"p",href:"/envs/services/testing"},"customizing an existing env with your tester")," or by ",(0,o.mdx)("a",{parentName:"p",href:"/envs/customizing-env"},"implementing your own Env"),"."),(0,o.mdx)("p",null,"Tester can also be implemented into Bit through few interfaces. \x3c!--TODO For more information on implementing your own compiler please refer to ",(0,o.mdx)("a",{parentName:"p",href:"/"},"Implement a Compiler"),".")))}u.__bit_component=r,u.isMDXComponent=!0},80987:(e,t,n)=>{var r={id:"teambit.defender/tester@1.0.184",homepage:"https://bit.cloud/teambit/defender/tester",exported:!0};function o(){const e=i(n(41594));return o=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,o.__bit_component=r,i.__bit_component=r;const a=()=>o().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},o().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/tester.svg"}));a.__bit_component=r,t.Logo=a},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React},65682:e=>{e.exports=TeambitMdxUiMdxScopeContext}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{compositions:()=>c,compositions_metadata:()=>f,overview:()=>u});var e={};n.r(e),n.d(e,{default:()=>m});var t=n(80987),o=(n(41594),n(5016)),i=n(65682),a=n(53300),s=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}var d={},l="wrapper";function m(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,s);return(0,o.mdx)(l,p({},d,n,{components:t,mdxType:"MDXLayout"}),(0,o.mdx)(i.MDXScopeProvider,{components:{TesterOverview:a.Ay},mdxType:"MDXScopeProvider"},(0,o.mdx)(a.Ay,{mdxType:"TesterOverview"})))}m.isMDXComponent=!0;const c=[t],u=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.defender/tester-preview"]=t():e["teambit.defender/tester-preview"]=t()}(self,(()=>(()=>{"use strict";var e={53300:(e,t,n)=>{Object.defineProperty(t,"Ay",{enumerable:!0,get:function(){return r.default}});var r=o(n(91204));function o(e){return e&&e.__esModule?e:{default:e}}o.__bit_component={id:"teambit.defender/content/tester-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/tester-overview",exported:!0}},91204:(e,t,n)=>{var r={id:"teambit.defender/content/tester-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/tester-overview",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=u,s(n(41594));var o=n(5016),i=n(65682),a=["components"];function s(e){return e&&e.__esModule?e:{default:e}}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}function d(e,t){if(null==e)return{};var n,r,o=l(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function l(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}s.__bit_component=r,p.__bit_component=r,d.__bit_component=r,l.__bit_component=r;var m={},c="wrapper";function u(e){var t=e.components,n=d(e,a);return(0,o.mdx)(c,p({},m,n,{components:t,mdxType:"MDXLayout"}),(0,o.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"},(0,o.mdx)("h1",null,"Tester Overview"),(0,o.mdx)("p",null,"The ",(0,o.mdx)("em",{parentName:"p"},"Tester")," provides a unified interface for testing components regardless of the specific tester they use."),(0,o.mdx)("p",null,"Software testing is a way to validate that an application or a module of it, behaves as expected."),(0,o.mdx)("p",null,"Web applications and services are often tested using a set of testing tools, where each tool plays a different role. For example, ",(0,o.mdx)("a",{parentName:"p",href:"https://jestjs.io/"},"Jest")," can be used as a test runner and as an assertion library, while ",(0,o.mdx)("a",{parentName:"p",href:"https://testing-library.com/"},"React Testing Library")," can be used for testing utilities."),(0,o.mdx)("p",null,"The Tester aspect is responsible for standardizing test execution for components; That is, it standardizes the way test runners are used. Other testing libraries used for utils, mocks, etc., are irrelevant, in that sense."),(0,o.mdx)("p",null,"Standardization is done for component testing during development (in the workspace) as well as for distribution (in a capsule ",", as part of the component ",(0,o.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"build pipeline"),")."),(0,o.mdx)("h2",null,"Testing in development"),(0,o.mdx)("p",null,"Bit tests all components in the ",(0,o.mdx)("a",{parentName:"p",href:"/workspace/overview"},"Workspace")," using just a single command. That is true for components of all types, regardless of their specific ",(0,o.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env"),", and as a consequence of that, their specific ",(0,o.mdx)("a",{parentName:"p",href:"/tester/overview"},"Tester implementation")," and configuration."),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit test\n")),(0,o.mdx)("p",null,"Components can be watched for changes and retested with a single command, as well."),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit test -w\n")),(0,o.mdx)("p",null,"To learn more on testing during development, please refer to ",(0,o.mdx)("a",{parentName:"p",href:"/tester/workspace-testing"},"Workspace Testing"),"."),(0,o.mdx)("h2",null,"Testing during build"),(0,o.mdx)("p",null,"Testing components for distribution is done during ",(0,o.mdx)("inlineCode",{parentName:"p"},"build")," by the Bit ",(0,o.mdx)("a",{parentName:"p",href:"/builder/overview"},"Builder"),"."),(0,o.mdx)("p",null,"Component build can be simulated with ",(0,o.mdx)("inlineCode",{parentName:"p"},"bit build")," and done through ",(0,o.mdx)("a",{parentName:"p",href:"/components/tags"},"Tag")," or ",(0,o.mdx)("a",{parentName:"p",href:"/components/snaps"},"Snap")),(0,o.mdx)("pre",null,(0,o.mdx)("code",{parentName:"pre",className:"language-bash"},"bit build\n")),(0,o.mdx)("p",null,"By default, Bit's pre-configured Envs includes a ",(0,o.mdx)("a",{parentName:"p",href:"/builder/overview#build-task"},"Build Task")," for testing components in the ",(0,o.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),", each using the Env's specific test configs."),(0,o.mdx)("p",null,"Testing during build provides the highest \"external validity\" by running tests on the distributable code that was generated by the Env's compiler and not by the tester's.\nThat way, the exact same code that will be consumed by other components, is tested before it is released. Moreover, since each component is tested in a capsule ",", isolated from the rest of the workspace, tests are guaranteed to provide results that are context-agnostic and free of false-positives."),(0,o.mdx)("h2",null,"Configuring and implementing Testers"),(0,o.mdx)("p",null,"Testers are configured in the ",(0,o.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env")," which is configured on your ",(0,o.mdx)("a",{parentName:"p",href:"/components/overview"},"Component"),". Customizing the Tester can be done by ",(0,o.mdx)("a",{parentName:"p",href:"/envs/services/testing"},"customizing an existing env with your tester")," or by ",(0,o.mdx)("a",{parentName:"p",href:"/envs/customizing-env"},"implementing your own Env"),"."),(0,o.mdx)("p",null,"Tester can also be implemented into Bit through few interfaces. \x3c!--TODO For more information on implementing your own compiler please refer to ",(0,o.mdx)("a",{parentName:"p",href:"/"},"Implement a Compiler"),".")))}u.__bit_component=r,u.isMDXComponent=!0},42561:(e,t,n)=>{var r={id:"teambit.defender/tester@1.0.186",homepage:"https://bit.cloud/teambit/defender/tester",exported:!0};function o(){const e=i(n(41594));return o=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,o.__bit_component=r,i.__bit_component=r;const a=()=>o().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},o().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/tester.svg"}));a.__bit_component=r,t.Logo=a},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React},65682:e=>{e.exports=TeambitMdxUiMdxScopeContext}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{compositions:()=>c,compositions_metadata:()=>f,overview:()=>u});var e={};n.r(e),n.d(e,{default:()=>m});var t=n(42561),o=(n(41594),n(5016)),i=n(65682),a=n(53300),s=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}var d={},l="wrapper";function m(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,s);return(0,o.mdx)(l,p({},d,n,{components:t,mdxType:"MDXLayout"}),(0,o.mdx)(i.MDXScopeProvider,{components:{TesterOverview:a.Ay},mdxType:"MDXScopeProvider"},(0,o.mdx)(a.Ay,{mdxType:"TesterOverview"})))}m.isMDXComponent=!0;const c=[t],u=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
@@ -934,7 +934,7 @@
934
934
  "_legacy": {
935
935
  "scope": "teambit.defender",
936
936
  "name": "tester",
937
- "version": "1.0.184"
937
+ "version": "1.0.186"
938
938
  },
939
939
  "_scope": "teambit.defender"
940
940
  }
@@ -3685,7 +3685,7 @@
3685
3685
  "_legacy": {
3686
3686
  "scope": "teambit.defender",
3687
3687
  "name": "tester",
3688
- "version": "1.0.184"
3688
+ "version": "1.0.186"
3689
3689
  },
3690
3690
  "_scope": "teambit.defender"
3691
3691
  }
@@ -5946,7 +5946,7 @@
5946
5946
  "componentId": {
5947
5947
  "scope": "teambit.defender",
5948
5948
  "name": "tester",
5949
- "version": "1.0.184"
5949
+ "version": "1.0.186"
5950
5950
  },
5951
5951
  "taggedModuleExports": []
5952
5952
  }
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_tester@1.0.184/dist/tester.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_tester@1.0.184/dist/tester.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_tester@1.0.186/dist/tester.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_tester@1.0.186/dist/tester.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -27,9 +27,9 @@ export declare class TestCmd implements Command {
27
27
  group: string;
28
28
  options: CommandOptions;
29
29
  constructor(tester: TesterMain, workspace: Workspace, logger: Logger);
30
- render([userPattern]: [string], { watch, debug, all, env, scope, junit, coverage, unmodified }: TestFlags): Promise<JSX.Element | {
30
+ report([userPattern]: [string], { watch, debug, all, env, scope, junit, coverage, unmodified }: TestFlags): Promise<"" | {
31
31
  code: number;
32
- data: JSX.Element;
32
+ data: string;
33
33
  }>;
34
34
  }
35
35
  export {};
package/dist/test.cmd.js CHANGED
@@ -32,20 +32,6 @@ function _constants() {
32
32
  };
33
33
  return data;
34
34
  }
35
- function _ink() {
36
- const data = require("ink");
37
- _ink = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- function _react() {
43
- const data = _interopRequireDefault(require("react"));
44
- _react = function () {
45
- return data;
46
- };
47
- return data;
48
- }
49
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
36
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
51
37
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
@@ -68,7 +54,7 @@ class TestCmd {
68
54
  // TODO: we need to reduce this redundant casting every time.
69
55
  ]);
70
56
  }
71
- async render([userPattern], {
57
+ async report([userPattern], {
72
58
  watch = false,
73
59
  debug = false,
74
60
  all = false,
@@ -97,11 +83,12 @@ class TestCmd {
97
83
  const patternWithScope = getPatternWithScope();
98
84
  const components = await this.workspace.getComponentsByUserInput(unmodified, patternWithScope, true);
99
85
  if (!components.length) {
86
+ const data = _chalk().default.bold(`no components found to test.
87
+ use "--unmodified" flag to test all components or specify the ids to test.
88
+ otherwise, only new and modified components will be tested`);
100
89
  return {
101
90
  code: 0,
102
- data: /*#__PURE__*/_react().default.createElement(_ink().Box, null, /*#__PURE__*/_react().default.createElement(_ink().Text, {
103
- bold: true
104
- }, "no components found to test. use \"--unmodified\" flag to test all components or specify the ids to test, otherwise, only new and modified components will be tested", ' '))
91
+ data
105
92
  };
106
93
  }
107
94
  this.logger.console(`testing total of ${components.length} components in workspace '${_chalk().default.cyan(this.workspace.name)}'`);
@@ -130,12 +117,11 @@ class TestCmd {
130
117
  const {
131
118
  seconds
132
119
  } = timer.stop();
133
- if (watch) return /*#__PURE__*/_react().default.createElement(_ink().Box, null);
120
+ if (watch) return '';
121
+ const data = `tests has been completed in ${_chalk().default.cyan(seconds.toString())} seconds.`;
134
122
  return {
135
123
  code,
136
- data: /*#__PURE__*/_react().default.createElement(_ink().Box, null, /*#__PURE__*/_react().default.createElement(_ink().Text, null, "tests has been completed in "), /*#__PURE__*/_react().default.createElement(_ink().Text, {
137
- color: "cyan"
138
- }, seconds, " "), /*#__PURE__*/_react().default.createElement(_ink().Text, null, "seconds."))
124
+ data
139
125
  };
140
126
  }
141
127
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_workspace","_timer","_constants","_ink","_react","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","TestCmd","constructor","tester","workspace","logger","name","description","COMPONENT_PATTERN_HELP","render","userPattern","watch","debug","all","env","scope","junit","coverage","unmodified","timer","Timer","create","scopeName","undefined","consoleWarning","start","OutsideWorkspaceError","getPatternWithScope","pattern","patternWithScope","components","getComponentsByUserInput","length","code","createElement","Box","Text","bold","console","chalk","cyan","off","tests","test","hasErrors","seconds","stop","color","exports"],"sources":["test.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Logger } from '@teambit/logger';\nimport { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { Box, Text } from 'ink';\nimport React from 'react';\nimport type { TesterMain } from './tester.main.runtime';\n\ntype TestFlags = {\n watch: boolean;\n debug: boolean;\n all: boolean;\n unmodified: boolean;\n env?: string;\n scope?: string;\n junit?: string;\n coverage?: boolean;\n};\n\nexport class TestCmd implements Command {\n name = 'test [component-pattern]';\n description = 'test components in the workspace. by default only runs tests for new and modified components';\n helpUrl = 'reference/testing/tester-overview';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n alias = 'at';\n group = 'development';\n options = [\n ['w', 'watch', 'start the tester in watch mode.'],\n ['d', 'debug', 'start the tester in debug mode.'],\n ['a', 'all', 'DEPRECATED. (use --unmodified)'],\n ['u', 'unmodified', 'test all components, not only new and modified'],\n ['', 'junit <filepath>', 'write tests results as JUnit XML format into the specified file path'],\n ['', 'coverage', 'show code coverage data'],\n ['e', 'env <id>', 'test only components assigned the given env'],\n [\n 's',\n 'scope <scope-name>',\n 'DEPRECATED. (use the pattern instead, e.g. \"scopeName/**\"). name of the scope to test',\n ],\n // TODO: we need to reduce this redundant casting every time.\n ] as CommandOptions;\n\n constructor(private tester: TesterMain, private workspace: Workspace, private logger: Logger) {}\n\n async render(\n [userPattern]: [string],\n { watch = false, debug = false, all = false, env, scope, junit, coverage = false, unmodified = false }: TestFlags\n ) {\n const timer = Timer.create();\n const scopeName = typeof scope === 'string' ? scope : undefined;\n if (scopeName) {\n this.logger.consoleWarning(\n `--scope is deprecated, use the pattern argument instead. e.g. \"scopeName/**\" for the entire scope`\n );\n }\n if (all) {\n unmodified = all;\n this.logger.consoleWarning(`--all is deprecated, use --unmodified instead`);\n }\n timer.start();\n if (!this.workspace) throw new OutsideWorkspaceError();\n\n const getPatternWithScope = () => {\n if (!userPattern && !scope) return undefined;\n const pattern = userPattern || '**';\n return scopeName ? `${scopeName}/${pattern}` : pattern;\n };\n const patternWithScope = getPatternWithScope();\n const components = await this.workspace.getComponentsByUserInput(unmodified, patternWithScope, true);\n if (!components.length) {\n return {\n code: 0,\n data: (\n <Box>\n <Text bold>\n no components found to test. use \"--unmodified\" flag to test all components or specify the ids to test,\n otherwise, only new and modified components will be tested{' '}\n </Text>\n </Box>\n ),\n };\n }\n\n this.logger.console(\n `testing total of ${components.length} components in workspace '${chalk.cyan(this.workspace.name)}'`\n );\n\n let code = 0;\n if (watch && !debug) {\n // avoid turning off the logger for non-watch scenario. otherwise, when this aspect throws errors, they'll be\n // swallowed. (Jest errors are shown regardless via Jest, but if the tester is unable to run Jest in the first\n // place, these errors won't be shown)\n this.logger.off();\n await this.tester.watch(components, {\n watch,\n debug,\n env,\n coverage,\n });\n } else {\n const tests = await this.tester.test(components, {\n watch,\n debug,\n env,\n junit,\n coverage,\n });\n if (tests.hasErrors()) code = 1;\n }\n const { seconds } = timer.stop();\n\n if (watch) return <Box></Box>;\n return {\n code,\n data: (\n <Box>\n <Text>tests has been completed in </Text>\n <Text color=\"cyan\">{seconds} </Text>\n <Text>seconds.</Text>\n </Box>\n ),\n };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA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;MACjB,MAAM,IAAI,CAACtC,MAAM,CAACQ,KAAK,CAACmB,UAAU,EAAE;QAClCnB,KAAK;QACLC,KAAK;QACLE,GAAG;QACHG;MACF,CAAC,CAAC;IACJ,CAAC,MAAM;MACL,MAAMyB,KAAK,GAAG,MAAM,IAAI,CAACvC,MAAM,CAACwC,IAAI,CAACb,UAAU,EAAE;QAC/CnB,KAAK;QACLC,KAAK;QACLE,GAAG;QACHE,KAAK;QACLC;MACF,CAAC,CAAC;MACF,IAAIyB,KAAK,CAACE,SAAS,CAAC,CAAC,EAAEX,IAAI,GAAG,CAAC;IACjC;IACA,MAAM;MAAEY;IAAQ,CAAC,GAAG1B,KAAK,CAAC2B,IAAI,CAAC,CAAC;IAEhC,IAAInC,KAAK,EAAE,oBAAOlC,MAAA,GAAAG,OAAA,CAAAsD,aAAA,CAAC1D,IAAA,GAAA2D,GAAG,MAAM,CAAC;IAC7B,OAAO;MACLF,IAAI;MACJ/D,IAAI,eACFO,MAAA,GAAAG,OAAA,CAAAsD,aAAA,CAAC1D,IAAA,GAAA2D,GAAG,qBACF1D,MAAA,GAAAG,OAAA,CAAAsD,aAAA,CAAC1D,IAAA,GAAA4D,IAAI,QAAC,8BAAkC,CAAC,eACzC3D,MAAA,GAAAG,OAAA,CAAAsD,aAAA,CAAC1D,IAAA,GAAA4D,IAAI;QAACW,KAAK,EAAC;MAAM,GAAEF,OAAO,EAAC,GAAO,CAAC,eACpCpE,MAAA,GAAAG,OAAA,CAAAsD,aAAA,CAAC1D,IAAA,GAAA4D,IAAI,QAAC,UAAc,CACjB;IAET,CAAC;EACH;AACF;AAACY,OAAA,CAAA/C,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_workspace","_timer","_constants","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","TestCmd","constructor","tester","workspace","logger","name","description","COMPONENT_PATTERN_HELP","report","userPattern","watch","debug","all","env","scope","junit","coverage","unmodified","timer","Timer","create","scopeName","undefined","consoleWarning","start","OutsideWorkspaceError","getPatternWithScope","pattern","patternWithScope","components","getComponentsByUserInput","length","chalk","bold","code","console","cyan","off","tests","test","hasErrors","seconds","stop","toString","exports"],"sources":["test.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Logger } from '@teambit/logger';\nimport { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport type { TesterMain } from './tester.main.runtime';\n\ntype TestFlags = {\n watch: boolean;\n debug: boolean;\n all: boolean;\n unmodified: boolean;\n env?: string;\n scope?: string;\n junit?: string;\n coverage?: boolean;\n};\n\nexport class TestCmd implements Command {\n name = 'test [component-pattern]';\n description = 'test components in the workspace. by default only runs tests for new and modified components';\n helpUrl = 'reference/testing/tester-overview';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n alias = 'at';\n group = 'development';\n options = [\n ['w', 'watch', 'start the tester in watch mode.'],\n ['d', 'debug', 'start the tester in debug mode.'],\n ['a', 'all', 'DEPRECATED. (use --unmodified)'],\n ['u', 'unmodified', 'test all components, not only new and modified'],\n ['', 'junit <filepath>', 'write tests results as JUnit XML format into the specified file path'],\n ['', 'coverage', 'show code coverage data'],\n ['e', 'env <id>', 'test only components assigned the given env'],\n [\n 's',\n 'scope <scope-name>',\n 'DEPRECATED. (use the pattern instead, e.g. \"scopeName/**\"). name of the scope to test',\n ],\n // TODO: we need to reduce this redundant casting every time.\n ] as CommandOptions;\n\n constructor(private tester: TesterMain, private workspace: Workspace, private logger: Logger) {}\n\n async report(\n [userPattern]: [string],\n { watch = false, debug = false, all = false, env, scope, junit, coverage = false, unmodified = false }: TestFlags\n ) {\n const timer = Timer.create();\n const scopeName = typeof scope === 'string' ? scope : undefined;\n if (scopeName) {\n this.logger.consoleWarning(\n `--scope is deprecated, use the pattern argument instead. e.g. \"scopeName/**\" for the entire scope`\n );\n }\n if (all) {\n unmodified = all;\n this.logger.consoleWarning(`--all is deprecated, use --unmodified instead`);\n }\n timer.start();\n if (!this.workspace) throw new OutsideWorkspaceError();\n\n const getPatternWithScope = () => {\n if (!userPattern && !scope) return undefined;\n const pattern = userPattern || '**';\n return scopeName ? `${scopeName}/${pattern}` : pattern;\n };\n const patternWithScope = getPatternWithScope();\n const components = await this.workspace.getComponentsByUserInput(unmodified, patternWithScope, true);\n if (!components.length) {\n const data = chalk.bold(`no components found to test.\nuse \"--unmodified\" flag to test all components or specify the ids to test.\notherwise, only new and modified components will be tested`);\n return {\n code: 0,\n data,\n };\n }\n\n this.logger.console(\n `testing total of ${components.length} components in workspace '${chalk.cyan(this.workspace.name)}'`\n );\n\n let code = 0;\n if (watch && !debug) {\n // avoid turning off the logger for non-watch scenario. otherwise, when this aspect throws errors, they'll be\n // swallowed. (Jest errors are shown regardless via Jest, but if the tester is unable to run Jest in the first\n // place, these errors won't be shown)\n this.logger.off();\n await this.tester.watch(components, {\n watch,\n debug,\n env,\n coverage,\n });\n } else {\n const tests = await this.tester.test(components, {\n watch,\n debug,\n env,\n junit,\n coverage,\n });\n if (tests.hasErrors()) code = 1;\n }\n const { seconds } = timer.stop();\n\n if (watch) return '';\n const data = `tests has been completed in ${chalk.cyan(seconds.toString())} seconds.`;\n return {\n code,\n data,\n };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;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GAAG,MAAM,IAAI,CAACpC,MAAM,CAACqC,IAAI,CAACV,UAAU,EAAE;QAC/CnB,KAAK;QACLC,KAAK;QACLE,GAAG;QACHE,KAAK;QACLC;MACF,CAAC,CAAC;MACF,IAAIsB,KAAK,CAACE,SAAS,CAAC,CAAC,EAAEN,IAAI,GAAG,CAAC;IACjC;IACA,MAAM;MAAEO;IAAQ,CAAC,GAAGvB,KAAK,CAACwB,IAAI,CAAC,CAAC;IAEhC,IAAIhC,KAAK,EAAE,OAAO,EAAE;IACpB,MAAMvC,IAAI,GAAI,+BAA8B6D,gBAAK,CAACI,IAAI,CAACK,OAAO,CAACE,QAAQ,CAAC,CAAC,CAAE,WAAU;IACrF,OAAO;MACLT,IAAI;MACJ/D;IACF,CAAC;EACH;AACF;AAACyE,OAAA,CAAA5C,OAAA,GAAAA,OAAA"}
@@ -36,7 +36,7 @@ export declare class TesterService implements EnvService<Tests, TesterDescriptor
36
36
  name: string;
37
37
  constructor(workspace: Workspace, logger: Logger, pubsub: PubSubEngine, devFiles: DevFilesMain);
38
38
  _callback: CallbackFn | undefined;
39
- render(env: EnvDefinition): JSX.Element;
39
+ render(env: EnvDefinition): string;
40
40
  getDescriptor(environment: EnvDefinition): {
41
41
  id: string;
42
42
  displayName: string;
@@ -11,20 +11,6 @@ function _path() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _react() {
15
- const data = _interopRequireDefault(require("react"));
16
- _react = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _ink() {
22
- const data = require("ink");
23
- _ink = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
14
  function _component() {
29
15
  const data = require("@teambit/component");
30
16
  _component = function () {
@@ -77,17 +63,13 @@ class TesterService {
77
63
  }
78
64
  render(env) {
79
65
  const descriptor = this.getDescriptor(env);
80
- return /*#__PURE__*/_react().default.createElement(_ink().Text, {
81
- key: descriptor?.id
82
- }, /*#__PURE__*/_react().default.createElement(_ink().Text, {
83
- color: "cyan"
84
- }, "configured tester: "), /*#__PURE__*/_react().default.createElement(_ink().Text, null, descriptor?.id, " (", descriptor?.displayName, " @ ", descriptor?.version, ")"), /*#__PURE__*/_react().default.createElement(_ink().Newline, null), /*#__PURE__*/_react().default.createElement(_ink().Text, {
85
- underline: true,
86
- color: "cyan"
87
- }, "tester config:"), /*#__PURE__*/_react().default.createElement(_ink().Newline, null), /*#__PURE__*/_react().default.createElement(_ink().Text, null, (0, _cliHighlight().default)(descriptor?.config || '', {
66
+ const name = `${chalk.green('configured tester:')} ${descriptor?.id} (${descriptor?.displayName} @ ${descriptor?.version})`;
67
+ const configLabel = chalk.green('tester config:');
68
+ const configObj = descriptor?.config ? (0, _cliHighlight().default)(descriptor?.config, {
88
69
  language: 'javascript',
89
70
  ignoreIllegals: true
90
- })), /*#__PURE__*/_react().default.createElement(_ink().Newline, null));
71
+ }) : '';
72
+ return `${name}\n${configLabel}\n${configObj}`;
91
73
  }
92
74
  getDescriptor(environment) {
93
75
  if (!environment.env.getTester) return undefined;
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_react","_interopRequireDefault","_ink","_component","_cliHighlight","_tester","_tester2","_utils","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","chalk","OnTestsChanged","exports","TesterService","constructor","workspace","logger","pubsub","devFiles","render","env","descriptor","getDescriptor","createElement","Text","id","color","displayName","version","Newline","underline","highlight","config","language","ignoreIllegals","environment","getTester","undefined","tester","icon","displayConfig","transform","context","onTestRunComplete","callback","_callback","run","options","specFiles","ComponentMap","as","components","component","detectTestFiles","testCount","toArray","reduce","acc","specs","length","componentWithTests","ui","consoleWarning","cyan","Tests","console","patterns","asAsync","componentDir","componentPatterns","getDevPatterns","TesterAspect","packageRootDir","getComponentPackagePath","paths","map","pattern","path","resolve","relative","additionalHostDependencies","getAdditionalTestHostDependencies","testerContext","assign","release","rootPath","debug","watch","coverage","results","forEach","publish","testsChanged","componentId","toString","testsResults","loading","test"],"sources":["tester.service.tsx"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport { resolve } from 'path';\nimport React from 'react';\nimport { Text, Newline } from 'ink';\nimport { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { ComponentMap } from '@teambit/component';\nimport { Workspace } from '@teambit/workspace';\nimport highlight from 'cli-highlight';\nimport { PubSubEngine } from 'graphql-subscriptions';\nimport { DevFilesMain } from '@teambit/dev-files';\nimport { Tester, Tests, CallbackFn } from './tester';\nimport { TesterAspect } from './tester.aspect';\nimport { TesterOptions } from './tester.main.runtime';\nimport { detectTestFiles } from './utils';\n\nconst chalk = require('chalk');\n\nexport const OnTestsChanged = 'OnTestsChanged';\n\ntype TesterTransformationMap = ServiceTransformationMap & {\n getTester: () => Tester;\n};\n\nexport type TesterDescriptor = {\n /**\n * id of the tester (e.g. jest/mocha)\n */\n id: string;\n\n /**\n * display name of the tester (e.g. Jest / Mocha)\n */\n displayName: string;\n\n /**\n * icon of the configured tester.\n */\n icon: string;\n\n /**\n * string containing the config for display.\n */\n config: string;\n\n version?: string;\n};\n\nexport class TesterService implements EnvService<Tests, TesterDescriptor> {\n name = 'tester';\n\n constructor(\n readonly workspace: Workspace,\n\n private logger: Logger,\n\n private pubsub: PubSubEngine,\n\n private devFiles: DevFilesMain\n ) {}\n\n _callback: CallbackFn | undefined;\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured tester: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text underline color=\"cyan\">\n tester config:\n </Text>\n <Newline />\n <Text>\n {/* refactor a separate component which highlights for cli */}\n {highlight(descriptor?.config || '', { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\n }\n\n getDescriptor(environment: EnvDefinition) {\n if (!environment.env.getTester) return undefined;\n const tester: Tester = environment.env.getTester();\n\n return {\n id: tester.id || '',\n displayName: tester.displayName || '',\n icon: tester.icon || '',\n config: tester.displayConfig ? tester.displayConfig() : '',\n version: tester.version ? tester.version() : '?',\n };\n }\n\n transform(env: Env, context: EnvContext): TesterTransformationMap | undefined {\n // Old env\n if (!env?.tester) return undefined;\n\n return {\n getTester: () => env.tester()(context),\n };\n }\n\n onTestRunComplete(callback: CallbackFn) {\n this._callback = callback;\n }\n\n async run(context: ExecutionContext, options: TesterOptions): Promise<Tests> {\n const tester: Tester = context.env.getTester();\n const specFiles = ComponentMap.as(context.components, (component) => {\n return detectTestFiles(component, this.devFiles);\n });\n const testCount = specFiles.toArray().reduce((acc, [, specs]) => acc + specs.length, 0);\n\n const componentWithTests = specFiles.toArray().reduce((acc: number, [, specs]) => {\n if (specs.length > 0) acc += 1;\n return acc;\n }, 0);\n\n if (testCount === 0 && !options.ui) {\n this.logger.consoleWarning(`no tests found for components using environment ${chalk.cyan(context.id)}\\n`);\n return new Tests([]);\n }\n\n if (!options.ui)\n this.logger.console(`testing ${componentWithTests} components with environment ${chalk.cyan(context.id)}\\n`);\n\n const patterns = await ComponentMap.asAsync(context.components, async (component) => {\n const componentDir = this.workspace.componentDir(component.id);\n const componentPatterns = this.devFiles.getDevPatterns(component, TesterAspect.id);\n const packageRootDir = await this.workspace.getComponentPackagePath(component);\n\n return {\n componentDir,\n packageRootDir,\n paths:\n componentPatterns.map((pattern: string) => ({\n path: resolve(componentDir, pattern),\n relative: pattern,\n })) || [],\n };\n });\n\n let additionalHostDependencies = [];\n if (\n context.env.getAdditionalTestHostDependencies &&\n typeof context.env.getAdditionalTestHostDependencies === 'function'\n ) {\n additionalHostDependencies = await context.env.getAdditionalTestHostDependencies();\n }\n\n const testerContext = Object.assign(context, {\n release: false,\n specFiles,\n patterns,\n rootPath: this.workspace.path,\n workspace: this.workspace,\n debug: options.debug,\n watch: options.watch,\n ui: options.ui,\n coverage: options.coverage,\n additionalHostDependencies,\n });\n\n if (options.watch && options.ui && tester.watch) {\n if (tester.onTestRunComplete) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n tester.onTestRunComplete((results) => {\n if (this._callback) this._callback(results);\n results.components.forEach((component) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.pubsub.publish(OnTestsChanged, {\n testsChanged: {\n id: component.componentId.toString(),\n testsResults: component.results,\n loading: component.loading,\n },\n });\n });\n });\n }\n\n return tester.watch(testerContext);\n }\n\n const results = await tester.test(testerContext);\n\n return results;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,cAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,aAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,SAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,QAAA,YA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,CAAChF,cAAc,EAAE;cAClCiF,YAAY,EAAE;gBACZnE,EAAE,EAAE2B,SAAS,CAACyC,WAAW,CAACC,QAAQ,CAAC,CAAC;gBACpCC,YAAY,EAAE3C,SAAS,CAACqC,OAAO;gBAC/BO,OAAO,EAAE5C,SAAS,CAAC4C;cACrB;YACF,CAAC,CAAC;UACJ,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;MAEA,OAAO1D,MAAM,CAACiD,KAAK,CAACL,aAAa,CAAC;IACpC;IAEA,MAAMO,OAAO,GAAG,MAAMnD,MAAM,CAAC2D,IAAI,CAACf,aAAa,CAAC;IAEhD,OAAOO,OAAO;EAChB;AACF;AAAC7E,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["_path","data","require","_component","_cliHighlight","_interopRequireDefault","_tester","_tester2","_utils","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","chalk","OnTestsChanged","exports","TesterService","constructor","workspace","logger","pubsub","devFiles","render","env","descriptor","getDescriptor","name","green","id","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","environment","getTester","undefined","tester","icon","displayConfig","transform","context","onTestRunComplete","callback","_callback","run","options","specFiles","ComponentMap","as","components","component","detectTestFiles","testCount","toArray","reduce","acc","specs","length","componentWithTests","ui","consoleWarning","cyan","Tests","console","patterns","asAsync","componentDir","componentPatterns","getDevPatterns","TesterAspect","packageRootDir","getComponentPackagePath","paths","map","pattern","path","resolve","relative","additionalHostDependencies","getAdditionalTestHostDependencies","testerContext","assign","release","rootPath","debug","watch","coverage","results","forEach","publish","testsChanged","componentId","toString","testsResults","loading","test"],"sources":["tester.service.ts"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport { resolve } from 'path';\nimport { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { ComponentMap } from '@teambit/component';\nimport { Workspace } from '@teambit/workspace';\nimport highlight from 'cli-highlight';\nimport { PubSubEngine } from 'graphql-subscriptions';\nimport { DevFilesMain } from '@teambit/dev-files';\nimport { Tester, Tests, CallbackFn } from './tester';\nimport { TesterAspect } from './tester.aspect';\nimport { TesterOptions } from './tester.main.runtime';\nimport { detectTestFiles } from './utils';\n\nconst chalk = require('chalk');\n\nexport const OnTestsChanged = 'OnTestsChanged';\n\ntype TesterTransformationMap = ServiceTransformationMap & {\n getTester: () => Tester;\n};\n\nexport type TesterDescriptor = {\n /**\n * id of the tester (e.g. jest/mocha)\n */\n id: string;\n\n /**\n * display name of the tester (e.g. Jest / Mocha)\n */\n displayName: string;\n\n /**\n * icon of the configured tester.\n */\n icon: string;\n\n /**\n * string containing the config for display.\n */\n config: string;\n\n version?: string;\n};\n\nexport class TesterService implements EnvService<Tests, TesterDescriptor> {\n name = 'tester';\n\n constructor(\n readonly workspace: Workspace,\n\n private logger: Logger,\n\n private pubsub: PubSubEngine,\n\n private devFiles: DevFilesMain\n ) {}\n\n _callback: CallbackFn | undefined;\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n const name = `${chalk.green('configured tester:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('tester config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\n }\n\n getDescriptor(environment: EnvDefinition) {\n if (!environment.env.getTester) return undefined;\n const tester: Tester = environment.env.getTester();\n\n return {\n id: tester.id || '',\n displayName: tester.displayName || '',\n icon: tester.icon || '',\n config: tester.displayConfig ? tester.displayConfig() : '',\n version: tester.version ? tester.version() : '?',\n };\n }\n\n transform(env: Env, context: EnvContext): TesterTransformationMap | undefined {\n // Old env\n if (!env?.tester) return undefined;\n\n return {\n getTester: () => env.tester()(context),\n };\n }\n\n onTestRunComplete(callback: CallbackFn) {\n this._callback = callback;\n }\n\n async run(context: ExecutionContext, options: TesterOptions): Promise<Tests> {\n const tester: Tester = context.env.getTester();\n const specFiles = ComponentMap.as(context.components, (component) => {\n return detectTestFiles(component, this.devFiles);\n });\n const testCount = specFiles.toArray().reduce((acc, [, specs]) => acc + specs.length, 0);\n\n const componentWithTests = specFiles.toArray().reduce((acc: number, [, specs]) => {\n if (specs.length > 0) acc += 1;\n return acc;\n }, 0);\n\n if (testCount === 0 && !options.ui) {\n this.logger.consoleWarning(`no tests found for components using environment ${chalk.cyan(context.id)}\\n`);\n return new Tests([]);\n }\n\n if (!options.ui)\n this.logger.console(`testing ${componentWithTests} components with environment ${chalk.cyan(context.id)}\\n`);\n\n const patterns = await ComponentMap.asAsync(context.components, async (component) => {\n const componentDir = this.workspace.componentDir(component.id);\n const componentPatterns = this.devFiles.getDevPatterns(component, TesterAspect.id);\n const packageRootDir = await this.workspace.getComponentPackagePath(component);\n\n return {\n componentDir,\n packageRootDir,\n paths:\n componentPatterns.map((pattern: string) => ({\n path: resolve(componentDir, pattern),\n relative: pattern,\n })) || [],\n };\n });\n\n let additionalHostDependencies = [];\n if (\n context.env.getAdditionalTestHostDependencies &&\n typeof context.env.getAdditionalTestHostDependencies === 'function'\n ) {\n additionalHostDependencies = await context.env.getAdditionalTestHostDependencies();\n }\n\n const testerContext = Object.assign(context, {\n release: false,\n specFiles,\n patterns,\n rootPath: this.workspace.path,\n workspace: this.workspace,\n debug: options.debug,\n watch: options.watch,\n ui: options.ui,\n coverage: options.coverage,\n additionalHostDependencies,\n });\n\n if (options.watch && options.ui && tester.watch) {\n if (tester.onTestRunComplete) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n tester.onTestRunComplete((results) => {\n if (this._callback) this._callback(results);\n results.components.forEach((component) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.pubsub.publish(OnTestsChanged, {\n testsChanged: {\n id: component.componentId.toString(),\n testsResults: component.results,\n loading: component.loading,\n },\n });\n });\n });\n }\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AAC;UAC3CA,OAAO,CAACtC,UAAU,CAACuC,OAAO,CAAEtC,SAAS,IAAK;YACxC;YACA,IAAI,CAAClC,MAAM,CAACyE,OAAO,CAAC/E,cAAc,EAAE;cAClCgF,YAAY,EAAE;gBACZlE,EAAE,EAAE0B,SAAS,CAACyC,WAAW,CAACC,QAAQ,CAAC,CAAC;gBACpCC,YAAY,EAAE3C,SAAS,CAACqC,OAAO;gBAC/BO,OAAO,EAAE5C,SAAS,CAAC4C;cACrB;YACF,CAAC,CAAC;UACJ,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;MAEA,OAAO1D,MAAM,CAACiD,KAAK,CAACL,aAAa,CAAC;IACpC;IAEA,MAAMO,OAAO,GAAG,MAAMnD,MAAM,CAAC2D,IAAI,CAACf,aAAa,CAAC;IAEhD,OAAOO,OAAO;EAChB;AACF;AAAC5E,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@teambit/tester",
3
- "version": "1.0.184",
3
+ "version": "1.0.186",
4
4
  "homepage": "https://bit.cloud/teambit/defender/tester",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.defender",
8
8
  "name": "tester",
9
- "version": "1.0.184"
9
+ "version": "1.0.186"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
- "ink": "3.2.0",
14
13
  "graphql-subscriptions": "1.2.0",
15
14
  "graphql-tag": "2.12.1",
16
15
  "fs-extra": "10.0.0",
@@ -24,17 +23,17 @@
24
23
  "@teambit/tests-results": "1.0.4",
25
24
  "@teambit/defender.ui.test-compare-section": "0.0.100",
26
25
  "@teambit/bit-error": "0.0.404",
27
- "@teambit/cli": "0.0.852",
28
- "@teambit/logger": "0.0.945",
29
- "@teambit/workspace": "1.0.184",
30
- "@teambit/envs": "1.0.184",
31
- "@teambit/component": "1.0.184",
32
- "@teambit/graphql": "1.0.184",
33
- "@teambit/builder": "1.0.184",
34
- "@teambit/dev-files": "1.0.184",
35
- "@teambit/ui": "1.0.184",
36
- "@teambit/compiler": "1.0.184",
37
- "@teambit/component-compare": "1.0.184",
26
+ "@teambit/cli": "0.0.854",
27
+ "@teambit/logger": "0.0.947",
28
+ "@teambit/workspace": "1.0.186",
29
+ "@teambit/envs": "1.0.186",
30
+ "@teambit/component": "1.0.186",
31
+ "@teambit/graphql": "1.0.186",
32
+ "@teambit/builder": "1.0.186",
33
+ "@teambit/dev-files": "1.0.186",
34
+ "@teambit/ui": "1.0.186",
35
+ "@teambit/compiler": "1.0.186",
36
+ "@teambit/component-compare": "1.0.186",
38
37
  "@teambit/defender.ui.test-compare": "0.0.260",
39
38
  "@teambit/defender.ui.test-page": "0.0.38"
40
39
  },
package/test.cmd.tsx DELETED
@@ -1,131 +0,0 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import chalk from 'chalk';
3
- import { Logger } from '@teambit/logger';
4
- import { OutsideWorkspaceError, Workspace } from '@teambit/workspace';
5
- import { Timer } from '@teambit/legacy/dist/toolbox/timer';
6
- import { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';
7
- import { Box, Text } from 'ink';
8
- import React from 'react';
9
- import type { TesterMain } from './tester.main.runtime';
10
-
11
- type TestFlags = {
12
- watch: boolean;
13
- debug: boolean;
14
- all: boolean;
15
- unmodified: boolean;
16
- env?: string;
17
- scope?: string;
18
- junit?: string;
19
- coverage?: boolean;
20
- };
21
-
22
- export class TestCmd implements Command {
23
- name = 'test [component-pattern]';
24
- description = 'test components in the workspace. by default only runs tests for new and modified components';
25
- helpUrl = 'reference/testing/tester-overview';
26
- arguments = [
27
- {
28
- name: 'component-pattern',
29
- description: COMPONENT_PATTERN_HELP,
30
- },
31
- ];
32
- alias = 'at';
33
- group = 'development';
34
- options = [
35
- ['w', 'watch', 'start the tester in watch mode.'],
36
- ['d', 'debug', 'start the tester in debug mode.'],
37
- ['a', 'all', 'DEPRECATED. (use --unmodified)'],
38
- ['u', 'unmodified', 'test all components, not only new and modified'],
39
- ['', 'junit <filepath>', 'write tests results as JUnit XML format into the specified file path'],
40
- ['', 'coverage', 'show code coverage data'],
41
- ['e', 'env <id>', 'test only components assigned the given env'],
42
- [
43
- 's',
44
- 'scope <scope-name>',
45
- 'DEPRECATED. (use the pattern instead, e.g. "scopeName/**"). name of the scope to test',
46
- ],
47
- // TODO: we need to reduce this redundant casting every time.
48
- ] as CommandOptions;
49
-
50
- constructor(private tester: TesterMain, private workspace: Workspace, private logger: Logger) {}
51
-
52
- async render(
53
- [userPattern]: [string],
54
- { watch = false, debug = false, all = false, env, scope, junit, coverage = false, unmodified = false }: TestFlags
55
- ) {
56
- const timer = Timer.create();
57
- const scopeName = typeof scope === 'string' ? scope : undefined;
58
- if (scopeName) {
59
- this.logger.consoleWarning(
60
- `--scope is deprecated, use the pattern argument instead. e.g. "scopeName/**" for the entire scope`
61
- );
62
- }
63
- if (all) {
64
- unmodified = all;
65
- this.logger.consoleWarning(`--all is deprecated, use --unmodified instead`);
66
- }
67
- timer.start();
68
- if (!this.workspace) throw new OutsideWorkspaceError();
69
-
70
- const getPatternWithScope = () => {
71
- if (!userPattern && !scope) return undefined;
72
- const pattern = userPattern || '**';
73
- return scopeName ? `${scopeName}/${pattern}` : pattern;
74
- };
75
- const patternWithScope = getPatternWithScope();
76
- const components = await this.workspace.getComponentsByUserInput(unmodified, patternWithScope, true);
77
- if (!components.length) {
78
- return {
79
- code: 0,
80
- data: (
81
- <Box>
82
- <Text bold>
83
- no components found to test. use "--unmodified" flag to test all components or specify the ids to test,
84
- otherwise, only new and modified components will be tested{' '}
85
- </Text>
86
- </Box>
87
- ),
88
- };
89
- }
90
-
91
- this.logger.console(
92
- `testing total of ${components.length} components in workspace '${chalk.cyan(this.workspace.name)}'`
93
- );
94
-
95
- let code = 0;
96
- if (watch && !debug) {
97
- // avoid turning off the logger for non-watch scenario. otherwise, when this aspect throws errors, they'll be
98
- // swallowed. (Jest errors are shown regardless via Jest, but if the tester is unable to run Jest in the first
99
- // place, these errors won't be shown)
100
- this.logger.off();
101
- await this.tester.watch(components, {
102
- watch,
103
- debug,
104
- env,
105
- coverage,
106
- });
107
- } else {
108
- const tests = await this.tester.test(components, {
109
- watch,
110
- debug,
111
- env,
112
- junit,
113
- coverage,
114
- });
115
- if (tests.hasErrors()) code = 1;
116
- }
117
- const { seconds } = timer.stop();
118
-
119
- if (watch) return <Box></Box>;
120
- return {
121
- code,
122
- data: (
123
- <Box>
124
- <Text>tests has been completed in </Text>
125
- <Text color="cyan">{seconds} </Text>
126
- <Text>seconds.</Text>
127
- </Box>
128
- ),
129
- };
130
- }
131
- }
@@ -1,193 +0,0 @@
1
- import { Logger } from '@teambit/logger';
2
- import { resolve } from 'path';
3
- import React from 'react';
4
- import { Text, Newline } from 'ink';
5
- import { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
6
- import { ComponentMap } from '@teambit/component';
7
- import { Workspace } from '@teambit/workspace';
8
- import highlight from 'cli-highlight';
9
- import { PubSubEngine } from 'graphql-subscriptions';
10
- import { DevFilesMain } from '@teambit/dev-files';
11
- import { Tester, Tests, CallbackFn } from './tester';
12
- import { TesterAspect } from './tester.aspect';
13
- import { TesterOptions } from './tester.main.runtime';
14
- import { detectTestFiles } from './utils';
15
-
16
- const chalk = require('chalk');
17
-
18
- export const OnTestsChanged = 'OnTestsChanged';
19
-
20
- type TesterTransformationMap = ServiceTransformationMap & {
21
- getTester: () => Tester;
22
- };
23
-
24
- export type TesterDescriptor = {
25
- /**
26
- * id of the tester (e.g. jest/mocha)
27
- */
28
- id: string;
29
-
30
- /**
31
- * display name of the tester (e.g. Jest / Mocha)
32
- */
33
- displayName: string;
34
-
35
- /**
36
- * icon of the configured tester.
37
- */
38
- icon: string;
39
-
40
- /**
41
- * string containing the config for display.
42
- */
43
- config: string;
44
-
45
- version?: string;
46
- };
47
-
48
- export class TesterService implements EnvService<Tests, TesterDescriptor> {
49
- name = 'tester';
50
-
51
- constructor(
52
- readonly workspace: Workspace,
53
-
54
- private logger: Logger,
55
-
56
- private pubsub: PubSubEngine,
57
-
58
- private devFiles: DevFilesMain
59
- ) {}
60
-
61
- _callback: CallbackFn | undefined;
62
-
63
- render(env: EnvDefinition) {
64
- const descriptor = this.getDescriptor(env);
65
- return (
66
- <Text key={descriptor?.id}>
67
- <Text color="cyan">configured tester: </Text>
68
- <Text>
69
- {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})
70
- </Text>
71
- <Newline />
72
- <Text underline color="cyan">
73
- tester config:
74
- </Text>
75
- <Newline />
76
- <Text>
77
- {/* refactor a separate component which highlights for cli */}
78
- {highlight(descriptor?.config || '', { language: 'javascript', ignoreIllegals: true })}
79
- </Text>
80
- <Newline />
81
- </Text>
82
- );
83
- }
84
-
85
- getDescriptor(environment: EnvDefinition) {
86
- if (!environment.env.getTester) return undefined;
87
- const tester: Tester = environment.env.getTester();
88
-
89
- return {
90
- id: tester.id || '',
91
- displayName: tester.displayName || '',
92
- icon: tester.icon || '',
93
- config: tester.displayConfig ? tester.displayConfig() : '',
94
- version: tester.version ? tester.version() : '?',
95
- };
96
- }
97
-
98
- transform(env: Env, context: EnvContext): TesterTransformationMap | undefined {
99
- // Old env
100
- if (!env?.tester) return undefined;
101
-
102
- return {
103
- getTester: () => env.tester()(context),
104
- };
105
- }
106
-
107
- onTestRunComplete(callback: CallbackFn) {
108
- this._callback = callback;
109
- }
110
-
111
- async run(context: ExecutionContext, options: TesterOptions): Promise<Tests> {
112
- const tester: Tester = context.env.getTester();
113
- const specFiles = ComponentMap.as(context.components, (component) => {
114
- return detectTestFiles(component, this.devFiles);
115
- });
116
- const testCount = specFiles.toArray().reduce((acc, [, specs]) => acc + specs.length, 0);
117
-
118
- const componentWithTests = specFiles.toArray().reduce((acc: number, [, specs]) => {
119
- if (specs.length > 0) acc += 1;
120
- return acc;
121
- }, 0);
122
-
123
- if (testCount === 0 && !options.ui) {
124
- this.logger.consoleWarning(`no tests found for components using environment ${chalk.cyan(context.id)}\n`);
125
- return new Tests([]);
126
- }
127
-
128
- if (!options.ui)
129
- this.logger.console(`testing ${componentWithTests} components with environment ${chalk.cyan(context.id)}\n`);
130
-
131
- const patterns = await ComponentMap.asAsync(context.components, async (component) => {
132
- const componentDir = this.workspace.componentDir(component.id);
133
- const componentPatterns = this.devFiles.getDevPatterns(component, TesterAspect.id);
134
- const packageRootDir = await this.workspace.getComponentPackagePath(component);
135
-
136
- return {
137
- componentDir,
138
- packageRootDir,
139
- paths:
140
- componentPatterns.map((pattern: string) => ({
141
- path: resolve(componentDir, pattern),
142
- relative: pattern,
143
- })) || [],
144
- };
145
- });
146
-
147
- let additionalHostDependencies = [];
148
- if (
149
- context.env.getAdditionalTestHostDependencies &&
150
- typeof context.env.getAdditionalTestHostDependencies === 'function'
151
- ) {
152
- additionalHostDependencies = await context.env.getAdditionalTestHostDependencies();
153
- }
154
-
155
- const testerContext = Object.assign(context, {
156
- release: false,
157
- specFiles,
158
- patterns,
159
- rootPath: this.workspace.path,
160
- workspace: this.workspace,
161
- debug: options.debug,
162
- watch: options.watch,
163
- ui: options.ui,
164
- coverage: options.coverage,
165
- additionalHostDependencies,
166
- });
167
-
168
- if (options.watch && options.ui && tester.watch) {
169
- if (tester.onTestRunComplete) {
170
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
171
- tester.onTestRunComplete((results) => {
172
- if (this._callback) this._callback(results);
173
- results.components.forEach((component) => {
174
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
175
- this.pubsub.publish(OnTestsChanged, {
176
- testsChanged: {
177
- id: component.componentId.toString(),
178
- testsResults: component.results,
179
- loading: component.loading,
180
- },
181
- });
182
- });
183
- });
184
- }
185
-
186
- return tester.watch(testerContext);
187
- }
188
-
189
- const results = await tester.test(testerContext);
190
-
191
- return results;
192
- }
193
- }