Add logjam example
This commit is contained in:
24
examples/logjam/package.json
Normal file
24
examples/logjam/package.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "logjam",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"start": "vitest --ui",
|
||||||
|
"test": "vitest"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/stevekinney/testing-javascript.git"
|
||||||
|
},
|
||||||
|
"author": "Steve Kinney <hello@stevekinney.net>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/stevekinney/testing-javascript/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/stevekinney/testing-javascript#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@vitest/ui": "^2.1.1",
|
||||||
|
"vite": "^5.4.5",
|
||||||
|
"vitest": "^2.1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
19
examples/logjam/src/log.js
Normal file
19
examples/logjam/src/log.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
export function log(...args) {
|
||||||
|
if (import.meta.env.MODE !== 'production') {
|
||||||
|
console.log(...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error = function error(...args) {
|
||||||
|
if (import.meta.env.MODE !== 'production') {
|
||||||
|
console.log(...args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
log.warn = function warn(...args) {
|
||||||
|
if (import.meta.env.MODE !== 'production') {
|
||||||
|
console.warn(...args);
|
||||||
|
}
|
||||||
|
};
|
||||||
14
examples/logjam/src/log.test.js
Normal file
14
examples/logjam/src/log.test.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { expect, it, vi, beforeEach, afterEach, describe } from 'vitest';
|
||||||
|
import { log } from './log';
|
||||||
|
|
||||||
|
describe.todo('logger', () => {
|
||||||
|
it('logs to the console in development mode', () => {
|
||||||
|
const spy = vi.spyOn(console, 'log');
|
||||||
|
|
||||||
|
log('Hello, world!');
|
||||||
|
|
||||||
|
expect(spy).toHaveBeenCalledWith('Hello, world!');
|
||||||
|
|
||||||
|
spy.mockRestore();
|
||||||
|
});
|
||||||
|
});
|
||||||
12
package-lock.json
generated
12
package-lock.json
generated
@@ -21,7 +21,8 @@
|
|||||||
"examples/scratchpad",
|
"examples/scratchpad",
|
||||||
"examples/utility-belt",
|
"examples/utility-belt",
|
||||||
"examples/strictly-speaking",
|
"examples/strictly-speaking",
|
||||||
"examples/button-factory"
|
"examples/button-factory",
|
||||||
|
"examples/logjam"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
@@ -128,6 +129,11 @@
|
|||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"examples/logjam": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {}
|
||||||
|
},
|
||||||
"examples/scratchpad": {
|
"examples/scratchpad": {
|
||||||
"extraneous": true
|
"extraneous": true
|
||||||
},
|
},
|
||||||
@@ -3308,6 +3314,10 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/logjam": {
|
||||||
|
"resolved": "examples/logjam",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/loose-envify": {
|
"node_modules/loose-envify": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -38,7 +38,8 @@
|
|||||||
"examples/scratchpad",
|
"examples/scratchpad",
|
||||||
"examples/utility-belt",
|
"examples/utility-belt",
|
||||||
"examples/strictly-speaking",
|
"examples/strictly-speaking",
|
||||||
"examples/button-factory"
|
"examples/button-factory",
|
||||||
|
"examples/logjam"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
|
|||||||
1
types.d.ts
vendored
Normal file
1
types.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
Reference in New Issue
Block a user