-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(testing): draw testing lib into its own package
- Loading branch information
1 parent
7163b32
commit 8950d82
Showing
19 changed files
with
110 additions
and
78 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,41 +1,6 @@ | ||
import { defineConfig } from 'vite'; | ||
import { ReadableStream } from 'node:stream/web'; | ||
import { createDiffReporter } from 'zora-reporters'; | ||
|
||
const createStream = ({ ws, client: _client }) => { | ||
let listener; | ||
return new ReadableStream({ | ||
start(controller) { | ||
listener = (data, client) => { | ||
if (client === _client) { | ||
if (data.type === 'STREAM_ENDED') { | ||
controller.close(); | ||
ws.off('zora', listener); | ||
} else { | ||
controller.enqueue(data); | ||
} | ||
} | ||
}; | ||
|
||
ws.on('zora', listener); | ||
}, | ||
}); | ||
}; | ||
const plugin = () => ({ | ||
name: 'zora-dev', | ||
async configureServer(server) { | ||
const report = createDiffReporter(); | ||
const socketStreams = new WeakMap(); | ||
|
||
server.ws.on('zora', async ({ type }, client) => { | ||
if (type === 'STREAM_STARTED') { | ||
const readableStream = createStream({ ws: server.ws, client }); | ||
await report(readableStream); | ||
} | ||
}); | ||
}, | ||
}); | ||
import zoraDev from '@cofn/test-lib/vite'; | ||
|
||
export default defineConfig({ | ||
plugins: [plugin()], | ||
plugins: [zoraDev()], | ||
}); |
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,27 @@ | ||
{ | ||
"name": "@cofn/test-lib", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"module": "./src/client/index.js", | ||
"style": "./src/client/theme.css", | ||
"scripts": {}, | ||
"exports": { | ||
"./package.json": "./package.json", | ||
"./client": { | ||
"import": "./src/client/index.js" | ||
}, | ||
"./client/theme.css": { | ||
"import": "./src/client/theme.css", | ||
"require": "./src/client/theme.css" | ||
}, | ||
"./vite": { | ||
"import": "./src/vite/index.js" | ||
} | ||
}, | ||
"author": "Laurent RENARD", | ||
"dependencies": { | ||
"zora": "^5.2.0", | ||
"zora-reporters": "^1.4.0" | ||
} | ||
} |
File renamed without changes.
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,3 @@ | ||
export * from './test.js'; | ||
export * from './socket-sink.js'; | ||
export * from './html-repoter.js'; |
Empty file.
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,18 @@ | ||
import { createHarness } from 'zora/es'; | ||
const createReporter = (messageStream) => { | ||
return new ReadableStream({ | ||
async pull(controller) { | ||
const { done, value } = await messageStream.next(); | ||
if (done) { | ||
controller.close(); | ||
return; | ||
} | ||
return controller.enqueue(value); | ||
}, | ||
}); | ||
}; | ||
|
||
const { test, skip, only, report: _report } = createHarness(); | ||
const report = () => _report({ reporter: createReporter }); | ||
|
||
export { test, skip, only, report }; |
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,36 @@ | ||
import { ReadableStream } from 'node:stream/web'; | ||
import { createDiffReporter } from 'zora-reporters'; | ||
|
||
const createStream = ({ ws, client: _client }) => { | ||
let listener; | ||
return new ReadableStream({ | ||
start(controller) { | ||
listener = (data, client) => { | ||
if (client === _client) { | ||
if (data.type === 'STREAM_ENDED') { | ||
controller.close(); | ||
ws.off('zora', listener); | ||
} else { | ||
controller.enqueue(data); | ||
} | ||
} | ||
}; | ||
|
||
ws.on('zora', listener); | ||
}, | ||
}); | ||
}; | ||
export default () => ({ | ||
name: 'zora-dev', | ||
async configureServer(server) { | ||
const report = createDiffReporter(); | ||
const socketStreams = new WeakMap(); | ||
|
||
server.ws.on('zora', async ({ type }, client) => { | ||
if (type === 'STREAM_STARTED') { | ||
const readableStream = createStream({ ws: server.ws, client }); | ||
await report(readableStream); | ||
} | ||
}); | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.