Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@asdgf/core
Advanced tools
@asdgf/core
A stupid simple way to test
No magic, no nonsense.
import { describe, executeTests } from '@asdgf/core';
import { expect } from '@open-wc/testing';
import { sum } from 'sum';
describe('sum', ({it, before, /* beforeEach, after, afterEach */}) => {
before(() => {
console.log('hello world');
});
it('adds two numbers', () => {
expect(sum(1,1)).to.equal(2);
});
});
/**
* Returns a test report
*/
executeTests().then(console.log);
You can also nest suites:
describe('foo', ({it, /* before, beforeEach, after, afterEach */}) => {
it('does foo', () => {
expect(true).to.equal(true);
});
/** Make sure to destructure `it` from the suite */
describe('bar', ({it}) => {
it('does bar', () => {
expect(true).to.equal(true);
});
});
});
import { describe } from 'asdgf';
import { expect, html } from '@open-wc/testing';
import { fixture, fixtureCleanup } from '@open-wc/testing-helpers/pure';
class MyEl extends HTMLElement {
connectedCallback() {
this.innerHTML = `hello world`;
}
}
customElements.define('my-el', MyEl);
describe('MyEl', ({it, afterEach}) => {
afterEach(fixtureCleanup);
it('renders', async () => {
const el = await fixture(html`<my-el></my-el>`);
expect(el.textContent).to.equal('hello world');
});
});
You can provide a custom renderer to render progress in the browser, or log progress to the console.
import { executeTests } from '@asdgf/core';
/**
* Log progress to the console
*/
const renderer = {
/** Runs before all suites run, depending on the integration */
start: () => {},
/** Runs before the suite starts, can be used for set up */
suiteStart: ({name, only, tests}) => {
console.log(`Starting suite: [${name}]`);
},
/** Runs after every ran test, whether it's skipped, passed, or failed */
renderTest: (testResult) => {
console.log(`${testResult.name}: ${testResult.passed ? '✅' : '❌'}`);
},
/** Runs after the entire suite has ran */
suiteEnd: (testSuiteResult) => {
console.log(`End of suite: [${testSuiteResult.name}]`);
},
/** Runs after all suites run, depending on the integration */
end: () => {}
}
executeTests({renderer});
import { executeTests } from '@asdgf/core';
import '@asdgf/ui/test-report.js';
/**
* Render progress to the browser
*/
const renderer = {
/** Runs after every ran test, whether it's skipped, passed, or failed */
renderTest: (testResult) => {
const result = document.createElement('test-result');
result.test = testResult;
document.body.appendChild(result);
},
}
executeTests({renderer});
npm i -D @asdgf/web-test-runner
web-test-runner.config.mjs
:
export default {
/**
* Point WTR to `asdgf` as the testFramework of choice
*/
testFramework: { path: 'node_modules/@asdgf/web-test-runner/index.js' },
};
This project was inspired by uvu.
FAQs
A stupid simple way to test
We found that @asdgf/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.