diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0eab328 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,22 @@ +# This config is equivalent to both the '.circleci/extended/orb-free.yml' and the base '.circleci/config.yml' +version: 2.1 + +jobs: + build: + docker: + - image: cypress/base:8 + environment: + ## this enables colors in the output + TERM: xterm + steps: + - checkout + - run: + name: Install npm + command: npm install + - run: + name: Install Cypress + command: npx cypress install + - run: + name: Run cypress ffs + command: npm run e2e:ci + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..dff5106 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: postdeploy + +on: [push, deployment_status, workflow_dispatch] + +jobs: + e2e: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2-beta + with: + node-version: 16 + + - name: Run Cypress + uses: cypress-io/github-action@v2 + with: + command: yarn e2e:ci + env: JS_APP_URL=https://bool-test-apps.onrender.com + config: video=true,screenshotOnRunFailure=true + + - name: Archive test screenshots + uses: actions/upload-artifact@v1 + with: + name: screenshots + path: cypress/screenshots + if: ${{ failure() }} + + - name: Archive test videos + uses: actions/upload-artifact@v1 + with: + name: videos + path: cypress/videos + if: ${{ failure() }} diff --git a/.gitignore b/.gitignore index f404a01..89aea86 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,9 @@ yarn-error.log* ### Output of 'npm pack' ### *.tgz + +### Cypress ### +cypress/results/* +cypress/reports/* +cypress/screenshots/* +cypress/videos/* diff --git a/cypress/integration/app.spec.ts b/cypress/integration/app.spec.ts index d37002f..9bbbdf4 100644 --- a/cypress/integration/app.spec.ts +++ b/cypress/integration/app.spec.ts @@ -10,8 +10,9 @@ const DATA_EXAMPLE = { }; describe('Core JS app', () => { - beforeEach(() => { + before(() => { cy.visit(Cypress.env('JS_APP_URL')); + cy.wait(4000); }); describe('getFeatures', () => { diff --git a/cypress/plugins/index.ts b/cypress/plugins/index.ts index 298ca61..0205d9c 100644 --- a/cypress/plugins/index.ts +++ b/cypress/plugins/index.ts @@ -21,7 +21,7 @@ module.exports = (on, config) => { // `config` is the resolved Cypress config // copy any needed variables from process.env to config.env - config.env.JS_APP_URL = 'http://localhost:3000/'; + config.env.JS_APP_URL = process.env.JS_APP_URL; // do not forget to return the changed config object! return config; diff --git a/package.json b/package.json index cc6991e..386c716 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "dev": "vite", "build": "tsc && vite build", "serve": "vite preview", - "e2e": "cypress open" + "e2e:local": "cypress open --env JS_APP_URL=https://e2e.usebool.com", + "e2e:ci": "cypress run --env JS_APP_URL=https://e2e.usebool.com" }, "dependencies": { "@usebool/sdk-js": "^0.1.5" diff --git a/src/main.ts b/src/main.ts index 1db791f..8a5b61f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,6 +36,8 @@ const composeSingularFeatures = async () => { const featureTwo = await featureFlags.hasFeature(keys[1].key); const featureThree = await featureFlags.hasFeature(keys[2].key); + console.log(JSON.stringify(featureOne)); + return [featureOne, featureTwo, featureThree] .map((actualValue, i) => SingleItem({ ...keys[i], actualValue })) .join('');