From 4140677c388216346a18f8a118a559f7f165b2d8 Mon Sep 17 00:00:00 2001 From: Oriol Raventos Date: Wed, 21 Feb 2024 17:10:42 +0100 Subject: [PATCH] chore(blank): update config for babel and jest --- blank/babel.config.js | 1 + blank/jest.config.js | 18 ++++++++++++++++++ blank/package.json | 36 +++++++++++++++--------------------- blank/tests/app.test.js | 11 ++++++----- 4 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 blank/jest.config.js diff --git a/blank/babel.config.js b/blank/babel.config.js index 55fa46e..ce0c91d 100644 --- a/blank/babel.config.js +++ b/blank/babel.config.js @@ -23,6 +23,7 @@ module.exports = { ], ], plugins: [ + require('@babel/plugin-transform-modules-commonjs'), require('@babel/plugin-transform-runtime'), ], } diff --git a/blank/jest.config.js b/blank/jest.config.js new file mode 100644 index 0000000..d2514ba --- /dev/null +++ b/blank/jest.config.js @@ -0,0 +1,18 @@ +const path = require('path') + +module.exports = { + rootDir: "tests", + transform: { + "^.+\\.jsx?$": [ + "babel-jest", + { "configFile": path.resolve(__dirname, "babel.config.js") }, + ], + }, + transformIgnorePatterns: [ + "/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx)$" + ], + moduleNameMapper: { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.js", + "\\.(scss|css|less)$": "/__mocks__/styleMock.js" + } +} \ No newline at end of file diff --git a/blank/package.json b/blank/package.json index eb78b5f..ee28976 100644 --- a/blank/package.json +++ b/blank/package.json @@ -7,46 +7,37 @@ "deploy": "botonic deploy -c build", "test": "jest" }, - "jest": { - "rootDir": "tests", - "transformIgnorePatterns": [ - "/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx|mjs)$" - ], - "moduleNameMapper": { - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.js", - "\\.(scss|css|less)$": "/__mocks__/styleMock.js" - } - }, "dependencies": { - "@babel/runtime": "^7.12.5", + "@babel/runtime": "^7.23.9", "@botonic/react": "0.25.0-alpha.4" }, "devDependencies": { "@babel/core": "^7.23.9", + "@babel/plugin-transform-modules-commonjs": "^7.23.3", "@babel/plugin-transform-runtime": "^7.23.9", "@babel/preset-env": "^7.23.9", "@babel/preset-react": "^7.23.3", "@hot-loader/react-dom": "^16.14.0", "analytics-node": "^3.5.0", "babel-jest": "^29.7.0", - "babel-loader": "^8.3.0", + "babel-loader": "^9.1.3", "chokidar": "^3.6.0", - "clean-webpack-plugin": "^3.0.0", - "css-loader": "^5.2.7", + "clean-webpack-plugin": "^4.0.0", + "css-loader": "^6.10.0", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.6.0", - "imagemin-gifsicle": "^6.0.1", - "imagemin-jpegtran": "^6.0.0", - "imagemin-optipng": "^7.1.0", - "imagemin-svgo": "^7.1.0", + "imagemin-gifsicle": "^7.0.0", + "imagemin-jpegtran": "^7.0.0", + "imagemin-optipng": "^8.0.0", + "imagemin-svgo": "^10.0.1", "imagemin-webpack": "^5.1.1", "jest": "^29.7.0", "null-loader": "^4.0.1", "process": "^0.11.10", "react-hot-loader": "4.12.21", - "sass": "^1.71.0", - "sass-loader": "^10.5.2", - "style-loader": "^2.0.0", + "sass": "^1.71.1", + "sass-loader": "^14.1.1", + "style-loader": "^3.3.4", "terser": "^5.27.2", "terser-webpack-plugin": "^5.3.10", "ts-node": "^10.9.2", @@ -54,5 +45,8 @@ "webpack": "^5.90.3", "webpack-cli": "^5.1.4", "webpack-dev-server": "5.0.2" + }, + "engines": { + "node": ">=20.0.0" } } diff --git a/blank/tests/app.test.js b/blank/tests/app.test.js index 18e0a44..13eba69 100644 --- a/blank/tests/app.test.js +++ b/blank/tests/app.test.js @@ -11,11 +11,12 @@ import { routes } from '../src/routes' const app = new NodeApp({ routes, locales, plugins, ...config }) -const i = new BotonicInputTester(app) -const o = new BotonicOutputTester(app) +const session = { user: { id: '123' } } +const input = new BotonicInputTester(app) +const output = new BotonicOutputTester(app) test('TEST: (404) NOT FOUND', async () => { - await expect(i.text('whatever')).resolves.toBe( - o.text("I don't understand you") - ) + console.log(input) + const response = await input.text('whatever', session) + expect(response).toBe(output.text("I don't understand you")) })