Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
dceb244
Initial plan
Copilot Apr 20, 2026
2deec04
Plan: migrate Mocha to Jest with --runInBand
Copilot Apr 21, 2026
173d0a3
fix: migrate Mocha to Jest with --runInBand, fix all cross-file depen…
Copilot Apr 21, 2026
43d0f21
refactor: simplify test1526 to use expect().toThrow() pattern
Copilot Apr 21, 2026
43769da
refactor: move skip-logic into test files, remove mocha, fix test624 …
Copilot Apr 21, 2026
2fb30f0
refactor: minimize describe body changes - move it.todo outside as te…
Copilot Apr 22, 2026
15cfb96
refactor: restore if(false) for test016a/160, use test.skip for empty…
Copilot Apr 23, 2026
5c39f85
Switch test runner from Jest to Bun (minimal test file changes)
Copilot Apr 24, 2026
503f5ad
fix: convert alasql(function(){/* SQL */}) pattern to template litera…
Copilot Apr 28, 2026
484d2da
chore: regenerate yarn.lock to fix frozen-lockfile CI failure
Copilot May 5, 2026
bde2b7b
Merge branch 'develop' into copilot/transition-mocha-to-jest
mathiasrw May 6, 2026
1dad863
feat: add --dots reporter to bun test command
Copilot May 6, 2026
ddaaf1a
Merge branch 'develop' into copilot/transition-mocha-to-jest
mathiasrw May 11, 2026
53020c9
style: fix prettier formatting in bun-setup.js, test257.js, test291.j…
Copilot May 11, 2026
ab68133
ci: remove bun from devDeps, install via setup-bun action in CI; fix …
Copilot May 12, 2026
69ee8fd
fix: make csvStringToNumber option work for direct CSV SELECT; fix te…
Copilot May 12, 2026
a7c8427
fix: remove this.timeout() from test2112.js test C (missed in earlier…
Copilot May 14, 2026
370a2a7
fix: upgrade axios resolution to 1.16.1 to resolve security vulnerabi…
Copilot May 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/Build and test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # master
with:
name: dist
Expand Down Expand Up @@ -172,6 +175,10 @@ jobs:
with:
files: src/alasqlparser.jison

- name: Setup Bun
if: steps.detect-changes.outputs.any_changed == 'true'
uses: oven-sh/setup-bun@v2

- name: Build from src
# This step only runs if the jison file changed
if: steps.detect-changes.outputs.any_changed == 'true'
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"scripts": {
"test": "sh build.sh && yarn test-only",
"test-ci": "(yarn test-format-all || 1) && yarn test-only && yarn install-g && alasql 'select 1 as Succes'",
"test-only": "node node_modules/mocha/bin/mocha.js ./test --reporter dot --bail",
"#test-only": "(command -v bun && bun node_modules/.bin/mocha ./test --reporter dot) || npx bun node_modules/.bin/mocha ./test --reporter dot",
"test-only": "bun test --dots --preload ./test/bun-setup.js ./test/test[0-9]*.js ./test/test-*.js",
"test-browser": "node test/browserTestRunner.js 7387",
"test-cover": "# istanbul cover -x 'lib/zt/zt.js' --dir test/coverage _mocha",
"build": "yarn format && yarn build-only",
Expand Down Expand Up @@ -69,8 +68,6 @@
"git-branch-is": "4.0.0",
"husky": "9.1.7",
"jison": "^0.4.18",
"mocha": "11.7.5",
"mocha.parallel": "0.15.6",
"open": "11.0.0",
"prettier": "3.8.3",
"react-native-fetch-blob": "^0.10.8",
Expand All @@ -81,7 +78,7 @@
},
"resolutions": {
"got": "15",
"axios": "^1.13.2",
"axios": "^1.16.1",
"json5": "2",
"underscore": "1",
"glob-parent": "6",
Expand All @@ -93,7 +90,7 @@
"rimraf": "^6.1.2"
},
"overrides": {
"axios": "^1.13.2",
"axios": "^1.16.1",
"follow-redirects": "^1.16.0",
"glob": "^13.0.0",
"rimraf": "^6.1.2"
Expand Down
4 changes: 2 additions & 2 deletions src/84from.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
alasql.utils.extend(opt, opts);
var res;
var hs = [];
// Determine once whether to auto-convert: not raw mode and not SELECT INTO
const shouldAutoConvert = !opt.raw && !query?.intofns;
// Determine once whether to auto-convert: not raw mode, not SELECT INTO, and csvStringToNumber option is set
const shouldAutoConvert = !opt.raw && !query?.intofns && alasql.options.csvStringToNumber;
Comment thread
mathiasrw marked this conversation as resolved.

function potentialAutoConvert(val) {
if (shouldAutoConvert && val !== undefined && val.length !== 0 && val == +val) {
Expand Down
17 changes: 17 additions & 0 deletions test/bun-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Provide Mocha-compatible before/after aliases for Bun's test runner.
// In Bun's preload context, beforeAll/afterAll are in the module scope
// (not on globalThis), so we define delegating wrappers on globalThis.
Object.defineProperty(globalThis, 'before', {
value: function (...args) {
return beforeAll(...args);
},
configurable: true,
writable: true,
});
Object.defineProperty(globalThis, 'after', {
value: function (...args) {
return afterAll(...args);
},
configurable: true,
writable: true,
});
8 changes: 6 additions & 2 deletions test/test-csv-string-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ describe('Test CSV string type preservation and column type conversion', functio
alasql('drop database test' + test);
});

it('A) CSV parser always keeps values as strings', function () {
it('A) CSV parser keeps values as strings when csvStringToNumber=false', function () {
alasql.options.csvStringToNumber = false;
Comment thread
mathiasrw marked this conversation as resolved.
var csvData = '"117.20";"500"\n"88.33";"600"';
var res = alasql('SELECT * FROM CSV(?, {separator:";", headers:false})', [csvData]);
assert.deepEqual(res, [
{0: '117.20', 1: '500'},
{0: '88.33', 1: '600'},
]);
alasql.options.csvStringToNumber = true; // Restore default
});

it('B) STRING type - preserves string values', function () {
Expand Down Expand Up @@ -170,10 +172,12 @@ describe('Test CSV string type preservation and column type conversion', functio
alasql('DROP TABLE test_tsv');
});

it('Q) Direct SELECT from CSV without INSERT returns strings', function () {
it('Q) Direct SELECT from CSV without INSERT returns strings when csvStringToNumber=false', function () {
alasql.options.csvStringToNumber = false;
Comment thread
mathiasrw marked this conversation as resolved.
var csvData = '"id";"name"\n"117.20";"test"';
var res = alasql('SELECT * FROM CSV(?, {separator:";"})', [csvData]);
assert.deepEqual(res, [{id: '117.20', name: 'test'}]);
alasql.options.csvStringToNumber = true; // Restore default
});

it('R) Unquoted CSV data - preserves strings when column is STRING', function () {
Expand Down
3 changes: 0 additions & 3 deletions test/test003.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,20 @@ describe('Test 03 - ' + NUMTESTS + 'times', function () {
});

it('3. Test insert without compilation #1', function (done) {
this.timeout(5000);
zt('Test insert without compilation #1', function () {
alasql(sql3);
});
done();
});

it('4. Test insert without compilation and caching', function (done) {
this.timeout(5000);
zt('Test insert without compilation and caching', function () {
alasql(sql3.replace('999', (Math.random() * 1000) | 0));
});
done();
});

it('5. Test compiled insert', function (done) {
this.timeout(5000);
var insert1 = alasql.compile(sql3);
zt('Test compiled insert', function () {
insert1();
Expand Down
2 changes: 1 addition & 1 deletion test/test029.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (typeof exports === 'object') {

describe('Test 29', function () {
it('JOIN USING', function (done) {
var db = alasql.Database('db');
var db = new alasql.Database('db');
db.exec('CREATE TABLE test1 (a int, b int)');
db.exec('INSERT INTO test1 VALUES (1,1)');
db.exec('INSERT INTO test1 VALUES (2,2)');
Expand Down
10 changes: 2 additions & 8 deletions test/test1526.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ describe('Test 1645', function () {
}
});

it('Throws error when callback for user function error', done => {
try {
alasql('SELECT medain(8)');
} catch (e) {
done();
}

throw 'error';
it('Throws error when callback for user function error', () => {
expect(() => alasql('SELECT medain(8)')).toThrow();
});

it('Catches error when promise for user function error', done => {
Expand Down
2 changes: 0 additions & 2 deletions test/test168.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if (typeof exports === 'object') {
//if(typeof exports === 'object' && false) {

describe('Test 168a - read XLSX', function () {
this.timeout(10000);
it('1. Read XLSX file', function (done) {
var res = alasql(
'select * from xlsx("' + dirname + '/test168.xlsx",{headers:false})',
Expand Down Expand Up @@ -68,7 +67,6 @@ describe('Test 168a - read XLSX', function () {
});

describe('Test 168b - read XLS', function () {
this.timeout(9000);
it('1. Read XLS file', function (done) {
var res = alasql(
'select * from xls("' + dirname + '/test168.xls",{headers:false})',
Expand Down
1 change: 0 additions & 1 deletion test/test2112.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('Test 2112 - load binary file', function () {
});

it('C) Loads HTTPS binary file (async)', function (done) {
this.timeout(15000);
alasql.utils.loadBinaryFile(
'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg',
true,
Expand Down
2 changes: 0 additions & 2 deletions test/test257.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (typeof exports === 'object') {
if (typeof exports != 'undefined') {
describe('Test 257 INTO XLS()', function () {
it('1. INTO XLS()', function (done) {
this.timeout(9000);

var data = [
{a: 1, b: 10},
{a: 2, b: 20},
Expand Down
1 change: 0 additions & 1 deletion test/test268.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Test 268 INNER JOIN stress test', function () {
//console.log(t2);

it('4. INNER JOIN on Big Array', function (done) {
this.timeout(10000);
var res = alasql('SELECT t1.*,t2.* FROM ? t1 INNER JOIN ? t2 ON t1.b = t2.b', [t1, t2]);
/// console.log('INNER =',res.length);
var res = alasql('SELECT t1.*,t2.* FROM ? t1 LEFT JOIN ? t2 ON t1.b = t2.b', [t1, t2]);
Expand Down
2 changes: 0 additions & 2 deletions test/test286.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ describe('Test 286 CREATE UNIQUE INDEX', function () {
});

it('2. Fill tables with data', () => {
this.timeout(100000);

var K = 10; // Number of runs
var P = 20; // Number of records coefficient

Expand Down
6 changes: 0 additions & 6 deletions test/test291.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ describe('Test 291 - Promises:', function () {
});

it('.promise all', function (done) {
this.timeout(2000); // dont get why this is timing out...

alasql
.promise(['SELECT VALUE 1'])
.then(function (res) {
Expand All @@ -34,17 +32,13 @@ describe('Test 291 - Promises:', function () {
});

it('.promise .catch exception', function (done) {
this.timeout(2000); // dont get why this is timing out...

alasql.promise('SELECT * FROM tableThatDoesNotExists').catch(function (err) {
assert(err instanceof Error);
done();
});
});

it('.promise all .catch exception', function (done) {
this.timeout(5000); // dont get why this is timing out...

alasql.promise(['SELECT * FROM tableThatDoesNotExists']).catch(function (err) {
assert(err instanceof Error);
done();
Expand Down
24 changes: 8 additions & 16 deletions test/test324.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ describe('Test 324 Roads samples', function () {
});

it('3. CREATE TABLE with constraints', function (done) {
var res = alasql(function () {
/*
var res = alasql(`
CREATE TABLE dbo.Employees
(
empid INT NOT NULL PRIMARY KEY,
Expand All @@ -49,21 +48,18 @@ describe('Test 324 Roads samples', function () {
salary MONEY NOT NULL,
CHECK (empid <> mgrid)
);
*/
});
`);
assert(res == 1);
assert(alasql.databases.dbo.tables.Employees);
done();
});

it('4. INSERT INTO table with constraints', function (done) {
var res = alasql(function () {
/*
var res = alasql(`
INSERT INTO dbo.Employees(empid, mgrid, empname, salary) VALUES
(1, NULL, 'David' , 10000.00),
(2, 1, 'Eitan' , 7000.00)
*/
});
`);
assert(res == 2);
assert.deepStrictEqual(alasql('SELECT * FROM dbo.Employees'), [
{empid: 1, mgrid: undefined, empname: 'David', salary: 10000},
Expand All @@ -74,25 +70,21 @@ describe('Test 324 Roads samples', function () {

it('5. INSERT INTO table with same primary key', function (done) {
assert.throws(function () {
var res = alasql(function () {
/*
var res = alasql(`
INSERT INTO dbo.Employees(empid, mgrid, empname, salary) VALUES
(1, NULL, 'David' , 10000.00),
(2, 1, 'Eitan' , 7000.00)
*/
});
`);
}, Error);
done();
});

it('6. INSERT INTO wrong NULL in NOT NULL column', function (done) {
assert.throws(function () {
var res = alasql(function () {
/*
var res = alasql(`
INSERT INTO dbo.Employees(empid, mgrid, empname, salary) VALUES
(NULL, 3, 'Samson' , 45000.00)
*/
});
`);
}, Error);
done();
});
Expand Down
6 changes: 2 additions & 4 deletions test/test325.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe('Test 325 IDENTITY', function () {
});

it('2. CREATE TABLE with multiple constraints', function (done) {
alasql(function () {
/*
alasql(`
IF OBJECT_ID('dbo.Messages') IS NOT NULL DROP TABLE dbo.Messages;
CREATE TABLE dbo.Messages
(
Expand All @@ -29,8 +28,7 @@ describe('Test 325 IDENTITY', function () {
CONSTRAINT CHK_Messages_status
CHECK (status IN('new', 'open', 'done'))
);
*/
});
`);
done();
});

Expand Down
Loading