Skip to content

Commit

Permalink
Prepare 0-dep qunitx package
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Jul 13, 2023
1 parent ae698ea commit e82f79a
Show file tree
Hide file tree
Showing 17 changed files with 7,887 additions and 2,696 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist
docs
tmp
.github
scripts
.gitignore
CHANGELOG.md
Dockerfile
Expand Down
12 changes: 1 addition & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
FROM node:20.4.0-slim

ENV PUPPETEER_SKIP_DOWNLOAD=true CHROME_BIN=/usr/bin/google-chrome-stable

RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y git libxshmfence-dev google-chrome-stable --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /code/

ADD package.json package-lock.json /code/

RUN npm install

ADD lib /code/lib
ADD shims /code/shims
ADD vendor /code/vendor
ADD test /code/test
ADD . /code/
Expand Down
92 changes: 0 additions & 92 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,92 +0,0 @@
Make it so 'qunitx' is a 0-dependency npm package, qunitx-cli the browser runner

- "$ qunitx sanity-test.ts" made redundant due to (node --test mode) this should impact dependencies and internal modules
- Implement other test cases in deno

Shim dir structure should be: shims/nodejs/ shims/deno shims/browser
Make package.json point to them correctly
Make the package so esbuild build so esbuild builds when qunitx is vendored(if it needs to)

Turn import { module, test } from '../../shims/nodejs.js' to import { module, test } from 'qunitx'; For this to happen browser bundler should pick up actual qunit

Combine nix with Docker for faster container builds

- also watch subdependencies on browser mode (-- how? investigate esbuild watch)
- maybe make browser tests per file loading <script>, also could add asset maps maybe if puppeteer supports, this could fix initial "qf" bug

implement and test require and timeout flags
implement concurrency

fix watcher for file removals make the logic smarter

allow passing absolutePaths(maybe)

- globs: test dynamically added file is watched on global input configuration | also check added files on watch gets put to config.fileOrFolderInputs
currently parse-fs-inputs might be less performant on big folders(?) dependending on how watch is implemented
- coverage
watch parsed files from html(?)


$ qunitx some-test --browser | default html doesnt match with $ qunitx init and also no html mode should be there

try this: $ npx ava --tap | npx tap-difflet
or this: $ npx ava --tap | npx faucet

research mocha reporter(TAP > reporters | json stream metada then it consumes this metadata(how?))
example good reporters: spec(reporter), dot, tap, landing strip(interesting instead put percentage), jest

esbuild ./tmp/test/passing-tests.js --bundle > test.js
parse qunitx in the package.json for config

failFast and babelOptions?
files(and to ignore), require, timeout
concurrencyStrategies

add node and browser options
add functionality to execute only one test
add reporters

pass timezone: https://stackoverflow.com/questions/16448754/how-to-use-a-custom-time-in-browser-to-test-for-client-vs-server-time-difference/39533934#39533934
= qunitx --timezone="US/Pacific"

QUnit regex filters

Jest Notes
==========
TestSequencer
- this failed in the past? run first
- when file changed latest
- this test run in the past and was long? long tests run first
- file size

TestScheduler
- schedule across threads
- reporters
- dont spawn many threads if total test count is small
jest-runner/jest-puppeteer(check this)

read jest-worker/worker_thread implementation


check if jest-qunit exists

jest-runtime(creates VM context)
allows module mocking, custom require implementation, also does transforms
runs the tests
transform is sync in jest(dep tracking problem)

TestResult / Repoter
- all data has to be json serializable for threads
- stack trace of errors
- how many assertions

AggregatedRestResult[]
- finished test case, how long, each assertion
- check jest runners

qunitx init


write test metadata(each test) if flag is provided

markdown reporter(interesting: https://mochajs.org/#markdown)
54 changes: 54 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import fs from 'fs/promises';

let [qunitJS, qunitCSS, _] = await Promise.all([
fs.readFile('./node_modules/qunit/qunit/qunit.js'),
fs.readFile('./node_modules/qunit/qunit/qunit.css'),
fs.mkdir('./vendor', { recursive: true })
]);

let newQUnit = qunitJS.toString().replace(
'start: function start(count) {',
`reset: function() {
ProcessingQueue.finished = false;
globalStartCalled = false;
runStarted = false;
config.queue.length = 0;
config.modules.length = 0;
config.autostart = false;
Object.assign(config.stats, { total: 0, passed: 0, failed: 0, skipped: 0, todo: 0 });
[
"started", "updateRate", "filter", "depth", "current",
"pageLoaded", "timeoutHandler", "timeout", "pollution"
].forEach( ( key ) => delete config[ key ] );
const suiteReport = config.currentModule.suiteReport;
suiteReport.childSuites.length = 0;
delete suiteReport._startTime;
delete suiteReport._endTime;
config.modules.push( config.currentModule );
},
start: function start(count) {`);

await Promise.all([
fs.writeFile('./vendor/qunit.js', newQUnit),
fs.writeFile('./vendor/qunit.css', qunitCSS),
createPackageJSONIfNotExists()
]);

async function createPackageJSONIfNotExists() {
try {
await fs.stat('./vendor/package.json');

return true;
} catch (error) {
await fs.writeFile('./vendor/package.json', JSON.stringify({
name: 'qunitx-vendor',
version: '0.0.1'
}));
}
}
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imports": {
"qunitx": "./shims/deno.js"
"qunitx": "./shims/deno/index.js"
}
}
}
11 changes: 11 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e82f79a

Please sign in to comment.