-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from izelnakri/watcher
initial --watch mode
- Loading branch information
Showing
21 changed files
with
1,096 additions
and
935 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
tmp | ||
vendor |
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 |
---|---|---|
|
@@ -5,3 +5,9 @@ dist | |
docs | ||
tmp | ||
.github | ||
scripts | ||
.gitignore | ||
CHANGELOG.md | ||
Dockerfile | ||
README.md | ||
TODO |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import QUnit from 'qunit'; | ||
import QUnit from './vendor/qunit.js'; | ||
|
||
QUnit.config.autostart = false; | ||
|
||
|
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,53 @@ | ||
import fs from 'fs/promises'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import esbuild from 'esbuild'; | ||
import setupBrowser from '../../setup/browser.js'; | ||
import parseFsInputs from '../../utils/parse-fs-inputs.js'; | ||
import timeCounter from '../../utils/time-counter.js'; | ||
import TAPDisplayFinalResult from '../../tap/display-final-result.js'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
export default async function runTestsInBrowser(fileOrFolderInputs, config, cachedContent = {}, connections) { | ||
const { projectRoot, timeout, output } = config; | ||
|
||
const fsTree = await parseFsInputs(fileOrFolderInputs, {}, async(targetPath, fsEntry) => { | ||
fsEntry.executed = false; | ||
}, config); | ||
|
||
await esbuild.build({ | ||
stdin: { | ||
contents: Object.keys(fsTree).reduce((result, fileAbsolutePath) => { | ||
return result + `import "${fileAbsolutePath}";` | ||
}, ''), | ||
resolveDir: process.cwd() | ||
}, | ||
bundle: true, | ||
logLevel: 'error', | ||
outfile: `${projectRoot}/${output}/tests.js` | ||
}); // NOTE: This prevents file cache most likely | ||
|
||
cachedContent.allTestCode = await fs.readFile(`${projectRoot}/${output}/tests.js`); | ||
// TODO: should I check something from config.htmlPaths at this point in the future?? NOTE: let htmlBuffers = await Promise.all(config.htmlPaths.map((htmlPath) => fs.readFile(`${projectRoot}/${htmlPath}`))); | ||
|
||
let TIME_COUNTER = timeCounter(); | ||
|
||
let { browser, server, WebSocketServer } = await setupBrowser(config, cachedContent, connections); | ||
|
||
let TIME_TAKEN = TIME_COUNTER.stop() | ||
|
||
TAPDisplayFinalResult(config.COUNTER, TIME_TAKEN); | ||
|
||
if (!config.watch) { | ||
await Promise.all([ | ||
server.close(), | ||
browser.close(), | ||
WebSocketServer.close() | ||
]); | ||
|
||
return process.exit(config.COUNTER.failCount > 0 ? 1 : 0); | ||
} | ||
|
||
return { server, browser, WebSocketServer }; | ||
} |
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,35 @@ | ||
import parseFsInputs from '../../utils/parse-fs-inputs.js'; | ||
|
||
let count = 0; | ||
|
||
export default async function runTestsInNode(fileOrFolderInputs, config) { | ||
config.COUNTER = { testCount: 0, failCount: 0, skipCount: 0, passCount: 0 }; | ||
|
||
global.testTimeout = config.timeout; | ||
|
||
let waitForTestCompletion = setupTestWaiting(); | ||
|
||
window.QUnit.reset(); | ||
|
||
const fsTree = await parseFsInputs(fileOrFolderInputs, {}, async (targetPath, fsEntry) => { | ||
count = count + 1; | ||
|
||
await import(`${targetPath}?${count}`); | ||
|
||
fsEntry.executed = true; | ||
}, config); | ||
|
||
console.log('TAP version 13'); | ||
window.QUnit.start(); | ||
|
||
await waitForTestCompletion; | ||
} | ||
|
||
function setupTestWaiting() { | ||
let finalizeTestCompletion; | ||
let promise = new Promise((resolve, reject) => finalizeTestCompletion = resolve); | ||
|
||
window.QUnit.done(() => finalizeTestCompletion()); | ||
|
||
return promise; | ||
} |
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
Oops, something went wrong.