diff --git a/.eslintrc.js b/.eslintrc.js index bfedad3..dc6d99a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 441b0d0..5f74e03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index ed98ca0..e8312a6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ docs/ # Misc .DS_Store + +# E2e tests artifacts +./__tests__/e2e/import-library/node_modules/ +./__tests__/e2e/import-library/export/package.tgz \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push index 614fa1b..992f82b 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,3 +1,2 @@ npx lint-staged -npm run test:ci -npm run test:e2e \ No newline at end of file +npm run test:ci \ No newline at end of file diff --git a/__tests__/e2e/import-library/import-library.test.ts b/__tests__/e2e/import-library/import-library.test.ts new file mode 100644 index 0000000..0cbe641 --- /dev/null +++ b/__tests__/e2e/import-library/import-library.test.ts @@ -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); + }); +}); diff --git a/__tests__/e2e/import-library/package-lock.json b/__tests__/e2e/import-library/package-lock.json new file mode 100644 index 0000000..ecbb9a7 --- /dev/null +++ b/__tests__/e2e/import-library/package-lock.json @@ -0,0 +1,21 @@ +{ + "name": "e2e-test", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "e2e-test", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@onebeyond/agnostic-cms-harmonizer": "file:../../../build" + } + }, + "../../../build": {}, + "node_modules/@onebeyond/agnostic-cms-harmonizer": { + "resolved": "../../../build", + "link": true + } + } +} diff --git a/__tests__/e2e/import-library/package.json b/__tests__/e2e/import-library/package.json new file mode 100644 index 0000000..3cfc9c0 --- /dev/null +++ b/__tests__/e2e/import-library/package.json @@ -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" + } +} diff --git a/__tests__/e2e/jest.e2e-config.js b/__tests__/e2e/jest.e2e-config.js index 5bf9f40..6a02f21 100644 --- a/__tests__/e2e/jest.e2e-config.js +++ b/__tests__/e2e/jest.e2e-config.js @@ -3,6 +3,6 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', verbose: true, - testRegex: '/cms/.*\\.test\\.ts$', + testRegex: '__tests__/e2e/.*\\.test\\.ts$', notify: true, }; diff --git a/package.json b/package.json index 2cc1b99..1973a20 100644 --- a/package.json +++ b/package.json @@ -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"