diff --git a/backend/lib/backend-lib.mjs b/backend/lib/backend-lib.mjs new file mode 100644 index 0000000..a0bf63a --- /dev/null +++ b/backend/lib/backend-lib.mjs @@ -0,0 +1,3 @@ +export function backend() { + return 'backend'; +} diff --git a/backend/package.json b/backend/package.json new file mode 100644 index 0000000..b62002e --- /dev/null +++ b/backend/package.json @@ -0,0 +1,33 @@ +{ + "name": "backend", + "version": "1.0.0", + "scripts": { + "test": "jest" + }, + "devDependencies": { + "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", + "jest": "^24.5.0" + }, + "jest": { + "testEnvironment": "node", + "testMatch": [ + "**/?(*.)(spec|test).?(m)js?(x)" + ], + "moduleFileExtensions": [ + "js", + "mjs" + ], + "transform": { + "^.+\\.m?js$": "babel-jest" + } + }, + "babel": { + "env": { + "test": { + "plugins": [ + "transform-es2015-modules-commonjs" + ] + } + } + } +} diff --git a/backend/use-backend-lib.test.mjs b/backend/use-backend-lib.test.mjs new file mode 100644 index 0000000..8e27311 --- /dev/null +++ b/backend/use-backend-lib.test.mjs @@ -0,0 +1,7 @@ +// Works fine + +import { backend } from './lib/backend-lib'; + +test('test using backend library', () => { + expect(backend()).toBeTruthy(); +}); diff --git a/backend/use-project-lib.test.mjs b/backend/use-project-lib.test.mjs new file mode 100644 index 0000000..e15ecc2 --- /dev/null +++ b/backend/use-project-lib.test.mjs @@ -0,0 +1,7 @@ +// Jest encountered an unexpected token + +import { foo } from '../lib/project-lib'; + +test('test using project-level library', () => { + expect(foo()).toBeTruthy(); +}); diff --git a/lib/project-lib.mjs b/lib/project-lib.mjs new file mode 100644 index 0000000..7efce94 --- /dev/null +++ b/lib/project-lib.mjs @@ -0,0 +1,3 @@ +export function foo() { + return 'foo'; +}