Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno investigation #3038

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
deno investigation
Your Name committed Jan 31, 2025
commit 3f1d67cb04498e9182013532bddaa3156ddc7979
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -212,3 +212,28 @@ jobs:
run: |
cd python
./run_tests.sh

deno:
runs-on: ubuntu-latest
name: testing BullMQ with Deno

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Install Dependencies
run: set +e; deno cache tests/*.ts --allow-scripts --unstable-sloppy-imports; set -e

- name: Run Deno Tests
run: deno run ./tests/example_deno_test.ts --unstable-sloppy-imports
25 changes: 25 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"imports": {
"events": "node:events",
"path": "node:path",
"fs": "https://deno.land/std@0.110.0/node/fs.ts",
"child_process": "node:child_process",
"worker_threads": "node:worker_threads",
"net": "node:net",
"util": "node:util",
"crypto": "node:crypto",
"url": "node:url",
"lodash": "https://raw.githubusercontent.com/lodash/lodash/4.17.21-es/lodash.js",
"msgpackr-extract@3.0.3": "npm:msgpackr-extract@3.0.3",
"process": "node:process",
"ioredis": "https://esm.sh/ioredis"
},
"compilerOptions": {
"strict": false,
"noImplicitAny": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"allowJs": true
},
"nodeModulesDir": "auto"
}
65 changes: 65 additions & 0 deletions tests/example_deno_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* First we import Mocha and it's type definitions.
*/
// @deno-types="https://unpkg.com/@types/mocha@7.0.2/index.d.ts"
import 'https://unpkg.com/mocha@7.2.0/mocha.js';
/**
* Here I'm using the Deno `expect` library, but you can use
* any assertion library - including Deno's std testing library.
* See: https://deno.land/std/testing
*/
import { expect } from 'https://deno.land/x/expect@v0.2.1/mod.ts';

/**
* Callback on completion of tests to ensure Deno exits with
* the appropriate status code.
*/
function onCompleted(failures: number): void {
if (failures > 0) {
Deno.exit(1);
} else {
Deno.exit(0);
}
}

/**
* Browser based Mocha requires `window.location` to exist.
*/
(window as any).location = new URL('http://localhost:0');

/**
* In order to use `describe` etc. we need to set Mocha to `bdd`
* mode.
*
* We also need to set the reporter to `spec` (though other options
* are available) to prevent Mocha using the default browser reporter
* which requires access to a DOM.
*/
mocha.setup({ ui: 'bdd', reporter: 'spec' });

/**
* Ensure there are no leaks in our tests.
*/
mocha.checkLeaks();

/**
* Our example function under test
*/
function add(a: number, b: number): number {
return a + b;
}

/**
* We write our tests as usual!
*/
describe('add', () => {
it('should add two positive numbers correctly', () => {
expect(add(2, 3)).toEqual(5);
});
});

/**
* And finally we run our tests, passing the onCompleted function
* hook and setting some globals.
*/
mocha.run(onCompleted).globals(['onerror']);