Test Model Configuration
packageSetup()
Signature
Section titled “Signature”packageSetup() — returns any
Available in: test
Category: Callback Functions
Description
Section titled “Description”The packageSetup() function is a callback in Wheels’ legacy testing framework. It runs once before the first test case in the test package. Use it to perform setup tasks that are shared across all tests in the package, such as initializing data, creating test records, or configuring environment settings.
Examples
Section titled “Examples”component extends="app.tests.Test" {
function packageSetup() {
// Run once before any test in this package
// Create a test user
model("user").new(username="testuser", email="test@example.com").save();
// Initialize test data
application.testConfig = {
siteName: "Wheels Test"
};
}
function test_User_Creation() {
var user = model("user").findOneByUsername("testuser");
assert("user eq true");
}
function test_Config_Value() {
assert("application.testConfig.siteName eq 'Wheels Test'");
}
}