Skip to content

Commit

Permalink
ci: create a e2e test to make sure the export works as expected (#101)
Browse files Browse the repository at this point in the history
* chore: update jest configuration

* test: add test for checking the library import

* test: add npm scripts to run import library tests

* chore: update prepush hook

* test: update test config

* chore: update gitignore

* ci: update test command to be run in the pipeline

* refactor: rename test name and test package json info

* fix: update circleCI command to run tests

* ci: update commands order

* refactor: simplify args for test scripts

* fix: modify the way of installing the library, second try

* fix: update eslint config to avoid import error

* fix: e2e local library

* fix: missing install deps e2e tests

* fix: ci install deps step also for e2e

* fix: npm i from external path e2e

* fix: e2e dedicated step deps

* fix: missing e2e local deps build

* ci: remove unused npm hooks and update gh action title

* chore: add pr feedback

---------

Co-authored-by: Àlex Serra <[email protected]>
  • Loading branch information
robertoHeCi and bounteous17 authored May 7, 2024
1 parent 74e5ab2 commit badc839
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @stylistic/max-len */
module.exports = {
ignorePatterns: ['docs', 'build'],
ignorePatterns: ['docs', 'build', 'import-library'],
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
- name: ⚙️ Install dependencies
run: npm ci

- name: ⚙️ Install e2e dependencies
run: npm --prefix __tests__/e2e/import-library/ i __tests__/e2e/import-library/ --no-save

- name: 🧪 Run tests
run: |
npm test
npm run test:e2e
run: npm run test:ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ docs/

# Misc
.DS_Store

# E2e tests artifacts
./__tests__/e2e/import-library/node_modules/
./__tests__/e2e/import-library/export/package.tgz
3 changes: 1 addition & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
npx lint-staged
npm run test:ci
npm run test:e2e
npm run test:ci
12 changes: 12 additions & 0 deletions __tests__/e2e/import-library/import-library.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ContentfulClient } from '@onebeyond/agnostic-cms-harmonizer';

describe('import-library', () => {
it('should check the imported library is an instance of ContentfulClient', () => {
const instance = new ContentfulClient({
accessToken: '',
space: '',
environment: '',
});
expect(instance).toBeInstanceOf(ContentfulClient);
});
});
21 changes: 21 additions & 0 deletions __tests__/e2e/import-library/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions __tests__/e2e/import-library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "e2e-test",
"version": "1.0.0",
"description": "Package json for testing purposes",
"author": "",
"license": "MIT",
"dependencies": {
"@onebeyond/agnostic-cms-harmonizer": "file:../../../build"
}
}
2 changes: 1 addition & 1 deletion __tests__/e2e/jest.e2e-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true,
testRegex: '/cms/.*\\.test\\.ts$',
testRegex: '__tests__/e2e/.*\\.test\\.ts$',
notify: true,
};
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
"docs:build": "npx typedoc",
"docs:build:watch": "npm run docs:build -- --watch",
"docs:serve": "PORT=4000 npx serve --no-clipboard docs",
"test": "npx jest",
"test:ci": "npm run test -- --ci --verbose false",
"test:watch": "npm run test -- --watchAll",
"test:e2e": "npm run test -- --config __tests__/e2e/jest.e2e-config.js",
"test:e2e:watch": "npm run test -- --config __tests__/e2e/jest.e2e-config.js --watchAll",
"test:unit": "npx jest",
"pretest:ci": "npm run build",
"test:ci": "npm run test:unit -- --ci && npm run test:e2e -- --ci",
"test:watch": "npx jest -- --watchAll",
"test:e2e": "npx jest --config __tests__/e2e/jest.e2e-config.js",
"test:e2e:watch": "npx jest --config __tests__/e2e/jest.e2e-config.js --watchAll",
"test:e2e:watch:inspect": "node --inspect ./node_modules/jest/bin/jest.js --config __tests__/e2e/jest.e2e-config.js --watchAll --testTimeout 999999",
"check-updates": "npx npm-check-updates -u",
"prepublishOnly": "npm run build"
Expand Down

0 comments on commit badc839

Please sign in to comment.