diff --git a/.github/workflows/branches.yml b/.github/workflows/branches.yml index 8e594df..799ced0 100644 --- a/.github/workflows/branches.yml +++ b/.github/workflows/branches.yml @@ -37,3 +37,15 @@ jobs: working-directory: ./webpack - run: yarn test working-directory: ./webpack + - run: yarn + working-directory: ./cjs-test + - run: yarn build + working-directory: ./cjs-test + - run: yarn test + working-directory: ./cjs-test + - run: yarn + working-directory: ./esm-test + - run: yarn build + working-directory: ./esm-test + - run: yarn test + working-directory: ./esm-test diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 756a2de..62edb51 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -36,6 +36,18 @@ jobs: working-directory: ./webpack - run: yarn test working-directory: ./webpack + - run: yarn + working-directory: ./cjs-test + - run: yarn build + working-directory: ./cjs-test + - run: yarn test + working-directory: ./cjs-test + - run: yarn + working-directory: ./esm-test + - run: yarn build + working-directory: ./esm-test + - run: yarn test + working-directory: ./esm-test release: name: Release diff --git a/cjs-test/jest.config.mjs b/cjs-test/jest.config.mjs new file mode 100644 index 0000000..14edfa3 --- /dev/null +++ b/cjs-test/jest.config.mjs @@ -0,0 +1,10 @@ +export default { + preset: 'ts-jest', + testEnvironment: 'node', + testMatch: [ + '/test/**/*.ts', + '/test/**/*.js', + ], + modulePathIgnorePatterns: [], + collectCoverage: false, +} diff --git a/cjs-test/package.json b/cjs-test/package.json new file mode 100644 index 0000000..1eb8a19 --- /dev/null +++ b/cjs-test/package.json @@ -0,0 +1,28 @@ +{ + "name": "awesome-phonenumber-test", + "license": "MIT", + "author": "Gustaf Räntilä ", + "engines": { + "node": ">=12" + }, + "main": "./index.js", + "types": "./index.d.ts", + "type": "commonjs", + "scripts": { + "postinstall:lib": "cd node_modules && ln -s ../.. awesome-phonenumber || true", + "postinstall:tests": "cp ../test/awesome-phonenumber/*.ts test", + "postinstall": "yarn postinstall:lib && yarn postinstall:tests", + "build": "tsc -p .", + "test": "jest" + }, + "devDependencies": { + "@babel/preset-env": "^7.17.10", + "@babel/preset-typescript": "^7.16.7", + "@types/jest": "^27.5.0", + "jest": "^28.1.0", + "ts-jest": "^28.0.2", + "ts-jest-resolver": "^2.0.0", + "ts-node": "^10.7.0", + "typescript": "^4.6.4" + } +} diff --git a/cjs-test/test/.gitkeep b/cjs-test/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/cjs-test/tsconfig.json b/cjs-test/tsconfig.json new file mode 100644 index 0000000..6c981d1 --- /dev/null +++ b/cjs-test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "lib": [ "es2019", "dom" ], + "moduleResolution": "node", + "module": "CommonJS", + "target": "es5", + "allowSyntheticDefaultImports": true + }, + "include": [ + "test" + ] +} diff --git a/esm-test/babel.config.cjs b/esm-test/babel.config.cjs new file mode 120000 index 0000000..57a080f --- /dev/null +++ b/esm-test/babel.config.cjs @@ -0,0 +1 @@ +../babel.config.cjs \ No newline at end of file diff --git a/esm-test/jest.config.mjs b/esm-test/jest.config.mjs new file mode 100644 index 0000000..e587f51 --- /dev/null +++ b/esm-test/jest.config.mjs @@ -0,0 +1,11 @@ +export default { + resolver: 'ts-jest-resolver', + testEnvironment: 'node', + testMatch: [ + '/test/**/*.ts', + '/test/**/*.js', + ], + modulePathIgnorePatterns: [], + collectCoverage: false, + extensionsToTreatAsEsm: ['.ts'], +} diff --git a/esm-test/package.json b/esm-test/package.json new file mode 100644 index 0000000..d156b6c --- /dev/null +++ b/esm-test/package.json @@ -0,0 +1,27 @@ +{ + "name": "awesome-phonenumber-test", + "license": "MIT", + "author": "Gustaf Räntilä ", + "engines": { + "node": ">=12" + }, + "main": "./index.js", + "types": "./index.d.ts", + "type": "module", + "scripts": { + "postinstall:lib": "cd node_modules && ln -s ../.. awesome-phonenumber || true", + "postinstall:tests": "cp ../test/awesome-phonenumber/*.ts test", + "postinstall": "yarn postinstall:lib && yarn postinstall:tests", + "build": "tsc -p .", + "test": "NODE_OPTIONS=--experimental-vm-modules jest" + }, + "devDependencies": { + "@babel/preset-env": "^7.17.10", + "@babel/preset-typescript": "^7.16.7", + "@types/jest": "^27.5.0", + "jest": "^28.1.0", + "ts-jest-resolver": "^2.0.0", + "ts-node": "^10.7.0", + "typescript": "^4.6.4" + } +} diff --git a/esm-test/test/.gitkeep b/esm-test/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/esm-test/tsconfig.json b/esm-test/tsconfig.json new file mode 100644 index 0000000..77920b1 --- /dev/null +++ b/esm-test/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "lib": [ "es2019", "dom" ], + "moduleResolution": "node", + "target": "ESNext", + "allowSyntheticDefaultImports": true + }, + "include": [ + "test" + ] +}