![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
classy-test
Advanced tools
Opinionated class based testing framework.
$ npm install classy-test
$ node node_modules/classy-test/bin/classy-test-cli.js
const ClassyTestRunner = require("classy-test");
new ClassyTestRunner().run();
Type: string[]
Default: ['test']
Relative paths to all directories that should be searched for test case files.
Type: string
(test file extension)
Default: '.test.js'
Set the default file extension for your test files.
Type: boolean
(disable interal classy test logging)
Default: false
This is used for our internal testing to make the logs cleaner. It is exposed has a "quality-of-life" feature.
my-project/lib/component.js
"use strict";
class SimpleComponent {
constructor(numbers) {
this.numbers = numbers;
}
sum() {
return this.numbers.reduce((a, b) => a + b);
}
sort() {
return this.numbers.sort();
}
}
module.exports = SimpleComponent;
my-project/test/component.test.js
"use strict";
const Component = require("../lib/component"),
classyTest = require("classy-test"),
assert = require("chai").assert;
// extend base test case.
class ComponentTestCase extends classyTest.BaseTestCase {
constructor() {
super();
}
// prefix all test functions in your test case with 'test'
testSum() {
assert.equal(new Component([1, 2, 3, 4]).sum(), 10);
}
testSort() {
assert.deepEqual(new Component([4, 1, 5, 2, 3]).sort(), [1, 2, 3, 4, 5]);
}
}
// export an array of test cases you want to run
module.exports = [
ComponentTestCase
];
"use strict";
const classyTest = require("../index.js"),
assert = require("chai").assert;
class Invoice {
// simulate async database interaction
static getById(id) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (id) {
resolve({
id: 123,
amount: 100,
currency: "USD"
});
} else {
reject(new Error("invoice_not_found"));
}
}, 200);
});
}
}
// test case for all your project needs
class ProjectBaseTestCase extends classyTest.BaseTestCase {
constructor() {
super();
}
setup() {
super.setup();
return this.bootstrapDatabase();
}
teardown() {
super.teardown();
return this.teardownDatabase();
}
bootstrapDatabase() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 500)
});
}
teardownDatabase() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 500)
});
}
}
// Simple test case extended our base project test case
class InvoiceTestCase extends ProjectBaseTestCase {
constructor() {
super();
}
testGetById() {
return Invoice.getById(123).then(invoice => {
assert.deepEqual(invoice, {
id: 123,
amount: 100,
currency: "USD"
});
}).catch(console.error);
}
testGetByIdError() {
return Invoice.getById(null).then(() => {
assert.isFalse(true, "the underlying promise should have failed. This block should never be run");
}).catch(error => {
assert.equal(error.message, "invoice_not_found");
});
}
}
module.exports = [InvoiceTestCase];
For more examples check here.
MIT © John Rake
FAQs
Opinionated class based testing framework
The npm package classy-test receives a total of 3 weekly downloads. As such, classy-test popularity was classified as not popular.
We found that classy-test 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.