-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(test): add browser test system * test(base): add suite on browser tests * refactor: rename browser tests * test(cache): add suite on browser tests * test(clear): add suite on browser tests * test(stale): add suite on browser tests * test(storage-base): add suite on browser tests * test(storage-memory): add suite on browser tests * test(ttl): add suite on browser tests * chore(storage): throw when runs in browser and redis * chore(memory): prevent undefined unref method * feat: add firefox support * feat: add safari support * refactor(abstract-logging): remove dependency and create factory * feat: add rollup bundler support * feat: add webpack bundler support * feat: add browserify bundler support * fix(bench): change createStorage path * chore(package): rename test browser script * feat(ci): add browser ci * chore(readme): add browser documentation * chore: reuse sleep helper method * perf(ci): cache playwright deps * perf(bundlers): dont include redis on browser bundles * feat(bundler): add vite support * chore(test): skip timer tests * chore(test): remove skipped tests * chore(readme): update browser specs * chore(util): comment abstractLogging method * chore(storage): remove istanbul and add test * chore(test-browser): remove duplicated tests * test(storage): add more specific tests * refactor: remove prepare command * ci(browser): remove prepare command
- Loading branch information
1 parent
f08b148
commit 341be35
Showing
24 changed files
with
756 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: browsers ci | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
pull_request: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] | ||
browser: ['chrome', 'firefox', 'safari', 'edge'] | ||
bundler: ['browserify', 'esbuild', 'rollup', 'vite', 'webpack'] | ||
exclude: | ||
- os: ubuntu-latest | ||
browser: safari | ||
- os: windows-latest | ||
browser: safari | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Restore cached playwright dependency | ||
uses: actions/cache@v3 | ||
id: playwright-cache | ||
with: | ||
path: | # playwright installs browsers into .local-browsers | ||
~/.cache/ms-playwright | ||
~/Library/Caches/ms-playwright | ||
%LOCALAPPDATA%\ms-playwright | ||
key: ${{ matrix.os }}-playwright-${{ hashFiles('package.json') }} | ||
|
||
- name: Restore cached dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ matrix.os }}-${{ hashFiles('package.json') }} | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Install browser | ||
run: ./node_modules/.bin/playwright install ${{ fromJSON('{"chrome":"chromium","edge":"msedge","firefox":"firefox","safari":"webkit"}')[matrix.browser] }} | ||
|
||
- name: Run Tests on Browsers | ||
run: npm run test:browser ${{ matrix.browser }} ${{ matrix.bundler }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,3 +108,6 @@ dist | |
.vscode | ||
docker-compose.yml | ||
dump.rdb | ||
|
||
# Temporary files used for browser testing | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as processModule from 'process' | ||
|
||
export const process = processModule | ||
|
||
export function setImmediate (fn, ...args) { | ||
setTimeout(() => fn(...args), 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { build } from 'esbuild' | ||
import alias from 'esbuild-plugin-alias' | ||
import { createRequire } from 'module' | ||
|
||
const require = createRequire(import.meta.url) | ||
|
||
build({ | ||
entryPoints: ['test/browser/test-browser.js'], | ||
outfile: 'tmp/esbuild/suite.browser.js', | ||
bundle: true, | ||
platform: 'browser', | ||
plugins: [ | ||
alias({ | ||
path: require.resolve('path-browserify'), | ||
stream: require.resolve('stream-browserify') | ||
}) | ||
], | ||
define: { | ||
global: 'globalThis' | ||
}, | ||
inject: ['test/browser/fixtures/esbuild.browser-shims.mjs'], | ||
external: ['./src/storage/redis.js'] | ||
}).catch((err) => { | ||
console.log(err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#output { | ||
margin: 30px; | ||
white-space: pre; | ||
font-family: monospace; | ||
} | ||
|
||
.error { | ||
display: block; | ||
width: calc(100% - 20px); | ||
background-color: #bb0000; | ||
padding: 10px; | ||
border-radius: 5px; | ||
margin: 10px 0; | ||
color: white; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="output"></div> | ||
|
||
<script type="text/javascript"> | ||
let failed = false | ||
const output = document.querySelector('#output') | ||
const originalLog = console.log | ||
const originalError = console.error | ||
|
||
console.log = function (message, ...args) { | ||
if (typeof message !== 'string') { | ||
originalLog(message, ...args) | ||
return | ||
} | ||
|
||
if (message.includes('not ok')) { | ||
failed = true | ||
document.body.style.backgroundColor = '#ff9d9d' | ||
} else if (message.includes('# async-cache-dedupe-finished') && !failed) { | ||
document.body.style.backgroundColor = '#9dff9d' | ||
} | ||
|
||
const span = document.createElement('span') | ||
span.textContent = message + '\n' | ||
output.appendChild(span) | ||
window.scrollTo(0, document.body.scrollHeight) | ||
originalLog(message, ...args) | ||
} | ||
|
||
console.error = function (message, ...args) { | ||
if (typeof message !== 'string') { | ||
originalError(message, ...args) | ||
return | ||
} | ||
|
||
const span = document.createElement('span') | ||
span.classList.add('error') | ||
span.textContent = message + '\n' | ||
output.appendChild(span) | ||
|
||
originalError(message, ...args) | ||
} | ||
</script> | ||
<script type="text/javascript" src="./suite.browser.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.