From 3062ab1e0314c8925727b906e152047a86b3f815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Uhl=C3=AD=C5=99?= Date: Tue, 31 Jan 2023 21:15:01 +0100 Subject: [PATCH] test: browser tests --- package-lock.json | 78 +++++++++++++++++++++++++++++++++++++++ package.json | 3 ++ playwright-test.config.js | 14 +++++++ 3 files changed, 95 insertions(+) create mode 100644 playwright-test.config.js diff --git a/package-lock.json b/package-lock.json index fedba437..61fa0b04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,8 @@ "@babel/preset-typescript": "^7.18.6", "@commitlint/cli": "^17.0.2", "@commitlint/config-conventional": "^17.4.2", + "@esbuild-plugins/node-globals-polyfill": "^0.2.3", + "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "@ethersphere/bee-factory": "^0.5.2", "@fluffy-spoon/substitute": "^1.208.0", "@naholyr/cross-env": "^1.0.0", @@ -2247,6 +2249,40 @@ "node": ">=10.0.0" } }, + "node_modules/@esbuild-plugins/node-globals-polyfill": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.2.3.tgz", + "integrity": "sha512-r3MIryXDeXDOZh7ih1l/yE9ZLORCd5e8vWg02azWRGj5SPTuoh69A2AIyn0Z31V/kHBfZ4HgWJ+OK3GTTwLmnw==", + "dev": true, + "peerDependencies": { + "esbuild": "*" + } + }, + "node_modules/@esbuild-plugins/node-modules-polyfill": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.2.2.tgz", + "integrity": "sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^4.0.0", + "rollup-plugin-node-polyfills": "^0.2.1" + }, + "peerDependencies": { + "esbuild": "*" + } + }, + "node_modules/@esbuild-plugins/node-modules-polyfill/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.2.1", "dev": true, @@ -9479,6 +9515,48 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup-plugin-inject": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz", + "integrity": "sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==", + "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.", + "dev": true, + "dependencies": { + "estree-walker": "^0.6.1", + "magic-string": "^0.25.3", + "rollup-pluginutils": "^2.8.1" + } + }, + "node_modules/rollup-plugin-inject/node_modules/estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, + "node_modules/rollup-plugin-node-polyfills": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz", + "integrity": "sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==", + "dev": true, + "dependencies": { + "rollup-plugin-inject": "^3.0.0" + } + }, + "node_modules/rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "dependencies": { + "estree-walker": "^0.6.1" + } + }, + "node_modules/rollup-pluginutils/node_modules/estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, "node_modules/run-parallel": { "version": "1.2.0", "dev": true, diff --git a/package.json b/package.json index 4631ff3d..adc930a2 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "build:browser": "webpack --progress", "mock-ci": "npm run lint:check && npm run check:types && npm run test", "test": "mocha", + "test:browser": "pw-test", "check:types": "tsc --project tsconfig.test.json", "lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"", @@ -82,6 +83,8 @@ "@babel/preset-typescript": "^7.18.6", "@commitlint/cli": "^17.0.2", "@commitlint/config-conventional": "^17.4.2", + "@esbuild-plugins/node-globals-polyfill": "^0.2.3", + "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "@ethersphere/bee-factory": "^0.5.2", "@fluffy-spoon/substitute": "^1.208.0", "@naholyr/cross-env": "^1.0.0", diff --git a/playwright-test.config.js b/playwright-test.config.js new file mode 100644 index 00000000..fb7c7376 --- /dev/null +++ b/playwright-test.config.js @@ -0,0 +1,14 @@ +const { NodeModulesPolyfillPlugin } = require('@esbuild-plugins/node-modules-polyfill') +const { NodeGlobalsPolyfillPlugin } = require('@esbuild-plugins/node-globals-polyfill') + +module.exports = { + buildConfig: { + plugins: [ + NodeModulesPolyfillPlugin(), + NodeGlobalsPolyfillPlugin({ + process: true, + buffer: true, + }), + ], + }, +}