"use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([["3824"],{7284:function(e,n,s){s.r(n),s.d(n,{default:()=>h,frontMatter:()=>r,metadata:()=>t,assets:()=>c,toc:()=>a,contentTitle:()=>l});var t=JSON.parse('{"id":"development/testing","title":"Testing COSMOS","description":"Running the Playwright integration tests and unit tests","source":"@site/docs/development/testing.md","sourceDirName":"development","slug":"/development/testing","permalink":"/tools/staticdocs/docs/development/testing","draft":false,"unlisted":false,"editUrl":"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/development/testing.md","tags":[],"version":"current","frontMatter":{"title":"Testing COSMOS","description":"Running the Playwright integration tests and unit tests","sidebar_custom_props":{"myEmoji":"\uD83D\uDCCB"}},"sidebar":"defaultSidebar","previous":{"title":"Streaming API","permalink":"/tools/staticdocs/docs/development/streaming-api"},"next":{"title":"Meta","permalink":"/tools/staticdocs/docs/meta"}}'),i=s("2322"),o=s("2840");let r={title:"Testing COSMOS",description:"Running the Playwright integration tests and unit tests",sidebar_custom_props:{myEmoji:"\uD83D\uDCCB"}},l=void 0,c={},a=[{value:"Playwright",id:"playwright",level:2},{value:"Prerequesits",id:"prerequesits",level:3},{value:"Playwright Testing",id:"playwright-testing",level:3},{value:"Ruby Unit Tests",id:"ruby-unit-tests",level:2},{value:"Python Unit Tests",id:"python-unit-tests",level:2}];function d(e){let n={code:"code",em:"em",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,o.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h2,{id:"playwright",children:"Playwright"}),"\n",(0,i.jsx)(n.h3,{id:"prerequesits",children:"Prerequesits"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Install Yarn"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"npm install --global yarn\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Clone the COSMOS Playwright repo"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/OpenC3/cosmos-playwright\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Install Playwright and dependencies"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn install\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"playwright-testing",children:"Playwright Testing"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Start COSMOS"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos % openc3.sh start\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:'Open COSMOS in your browser. At the login screen, set the password to "password".'}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Run tests (Note the --headed option visually displays tests, leave it off to run in the background)"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn playwright test --project=chromium --headed\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.em,{children:"[Optional]"})," Fix istanbul/nyc coverage source lookups (use ",(0,i.jsx)(n.code,{children:"fixwindows"})," if not on Linux)."]}),"\n",(0,i.jsx)(n.p,{children:"Tests will run successfully without this step and you will get coverage statistics, but line-by-line coverage won't work."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn fixlinux\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Generate code coverage"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn coverage\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Code coverage reports can be viewed at ",(0,i.jsx)(n.code,{children:"openc3-playwright/coverage/index.html"})]}),"\n",(0,i.jsx)(n.h2,{id:"ruby-unit-tests",children:"Ruby Unit Tests"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["Navigate to ",(0,i.jsx)(n.strong,{children:"cosmos/openc3"})," folder. Run the command:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos/openc3 % rake build\ncosmos/openc3 % bundle exec rspec\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Code coverage reports can be found at ",(0,i.jsx)(n.code,{children:"cosmos/openc3/coverage/index.html"})]}),"\n",(0,i.jsx)(n.h2,{id:"python-unit-tests",children:"Python Unit Tests"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["Navigate to ",(0,i.jsx)(n.strong,{children:"cosmos/openc3/python"})," folder. Run the command:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cosmos/openc3/python % python -m pip install -r requirements-dev.txt\ncosmos/openc3/python % python -m pip install -r requirements.txt\ncosmos/openc3/python % coverage run -m pytest\ncosmos/openc3/python % coverage html\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Code coverage reports can be found at ",(0,i.jsx)(n.code,{children:"cosmos/openc3/python/coverage/index.html"})]})]})}function h(e={}){let{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},2840:function(e,n,s){s.d(n,{Z:function(){return l},a:function(){return r}});var t=s(2784);let i={},o=t.createContext(i);function r(e){let n=t.useContext(o);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);