Skip to content

Commit

Permalink
Merge pull request #8393 from trunk-io/add-karma-framework
Browse files Browse the repository at this point in the history
add karma and it's dependencies
  • Loading branch information
joshmarinacci authored Oct 2, 2024
2 parents 27c73f0 + 44b75fd commit e966584
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
31 changes: 31 additions & 0 deletions javascript/tests/karma/karma-mocha-tests.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// import assert from "assert";
const assert = require('assert')

describe("Even - minute is divisible by 2", () => {
it("should verify that the current minute is even", () => {
const today = new Date();
const currentMinute = today.getMinutes();

assert.strictEqual(currentMinute % 2, 0);
});
});

describe("Odd - minute is divisible by 1", () => {
it("should verify that the current minute is odd", () => {
const today = new Date();
const currentMinute = today.getMinutes();

assert.strictEqual(currentMinute % 2, 1);
});
});

describe("X equals 3", function () {
let X = 0; // X starts at 0
this.retries(5); // Retry up to 3 times

it("should pass on 2nd auto-retry", () => {
// Increment X
X++;
assert.strictEqual(X, 3);
});
});
81 changes: 81 additions & 0 deletions javascript/tests/karma/my.conf.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Karma configuration
// Generated on Mon Sep 30 2024 11:45:38 GMT-0700 (Pacific Daylight Time)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
frameworks: ['mocha','browserify'],


// list of files / patterns to load in the browser
files: [
{ pattern: './karma-mocha-tests.cjs', included: true }
],


// list of files / patterns to exclude
exclude: [
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
preprocessors: {
'./karma-mocha-tests.cjs': [ 'browserify' ]
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
reporters: ['progress','junit'],

junitReporter:{
outputDir: 'test-output',
outputFile:'karma-output.xml',
suite:'my-test-suite',
useBrowserName:false,
// function (browser, result) to customize the name attribute in xml testcase element
nameFormatter: function(browser, result) { return "cool-name"},
// function (browser, result) to customize the classname attribute in xml testcase element
// classNameFormatter: undefined,
classNameFormatter: function(browser,result) { return "cool-class-name" }
},

// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: ['Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser instances should be started simultaneously
concurrency: Infinity
})
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"karma": "^6.4.4",
"karma-chrome-launcher": "^3.2.0",
"karma-browserify": "^8.1.0",
"browserify": "^17.0.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-requirejs": "^1.1.0",
"mocha": "^8.4.0",
"mocha-junit-reporter": "^2.0.0",
"typescript": "^5.4.3"
Expand Down

0 comments on commit e966584

Please sign in to comment.