Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/test-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
matrix:
os:
- ubuntu-latest
node-version: ["20.x", "22.x", "24.x"]
node-version: ["22.x", "24.x", "26.x"]
include:
- os: windows-latest
node-version: "22.x"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- [JavaScript] BREAKING CHANGE: Switch to ESM ([#173](https://github.com/cucumber/query/pull/173))

## [15.0.1] - 2026-01-22
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion javascript/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": ["ts-node/register"],
"node-option": ["loader=ts-node/esm"],
"extension": ["ts"],
"recursive": true,
"spec": ["src/**/*.spec.*"],
Expand Down
3 changes: 2 additions & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"name": "@cucumber/query",
"version": "15.0.1",
"description": "Cucumber Query - query messages",
"type": "commonjs",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"clean": "rm -rf dist",
"fix": "biome check --fix --error-on-warnings",
"lint": "biome check --error-on-warnings",
"postbuild": "node -e \"require('.')\"",
"test": "mocha",
"prepublishOnly": "tsc -p tsconfig.build.json"
},
Expand Down
24 changes: 15 additions & 9 deletions javascript/src/Query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import path from 'node:path'

import type { Envelope, TestCaseStarted } from '@cucumber/messages'

import type { Lineage } from './Lineage'
import Query from './Query'
import type { Lineage } from './Lineage.js'
import Query from './Query.js'

describe('Query', () => {
let cucumberQuery: Query
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Query', () => {
describe('#findLineageBy', () => {
it('returns correct lineage for a minimal scenario', async () => {
const envelopes: ReadonlyArray<Envelope> = (
await fs.readFile(path.join(__dirname, '../../testdata/src/minimal.ndjson'), {
await fs.readFile(path.join(import.meta.dirname, '../../testdata/src/minimal.ndjson'), {
encoding: 'utf-8',
})
)
Expand All @@ -116,9 +116,12 @@ describe('Query', () => {

it('returns correct lineage for a pickle from an examples table', async () => {
const envelopes: ReadonlyArray<Envelope> = (
await fs.readFile(path.join(__dirname, '../../testdata/src/examples-tables.ndjson'), {
encoding: 'utf-8',
})
await fs.readFile(
path.join(import.meta.dirname, '../../testdata/src/examples-tables.ndjson'),
{
encoding: 'utf-8',
}
)
)
.split('\n')
.filter((line) => !!line)
Expand Down Expand Up @@ -147,9 +150,12 @@ describe('Query', () => {

it('returns correct lineage for a pickle with background-derived steps', async () => {
const envelopes: ReadonlyArray<Envelope> = (
await fs.readFile(path.join(__dirname, '../../testdata/src/rules-backgrounds.ndjson'), {
encoding: 'utf-8',
})
await fs.readFile(
path.join(import.meta.dirname, '../../testdata/src/rules-backgrounds.ndjson'),
{
encoding: 'utf-8',
}
)
)
.split('\n')
.filter((line) => !!line)
Expand Down
4 changes: 2 additions & 2 deletions javascript/src/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import {
import { ArrayMultimap } from '@teppeis/multimaps'
import sortBy from 'lodash.sortby'

import { assert, statusOrdinal } from './helpers'
import type { Lineage } from './Lineage'
import { assert, statusOrdinal } from './helpers.js'
import type { Lineage } from './Lineage.js'

export default class Query {
private meta: Meta
Expand Down
25 changes: 14 additions & 11 deletions javascript/src/acceptance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { pipeline } from 'node:stream/promises'
import { NdjsonToMessageStream } from '@cucumber/message-streams'
import type { Envelope, Pickle } from '@cucumber/messages'

import Query from './Query'
import Query from './Query.js'

const reversePickleComparator = (a: Pickle, b: Pickle): number => {
if (a.uri !== b.uri) {
Expand All @@ -21,15 +21,15 @@ const reversePickleComparator = (a: Pickle, b: Pickle): number => {

describe('Acceptance Tests', async () => {
const sources = [
path.join(__dirname, '../../testdata/src/attachments.ndjson'),
path.join(__dirname, '../../testdata/src/empty.ndjson'),
path.join(__dirname, '../../testdata/src/global-hooks.ndjson'),
path.join(__dirname, '../../testdata/src/global-hooks-attachments.ndjson'),
path.join(__dirname, '../../testdata/src/hooks.ndjson'),
path.join(__dirname, '../../testdata/src/minimal.ndjson'),
path.join(__dirname, '../../testdata/src/rules.ndjson'),
path.join(__dirname, '../../testdata/src/examples-tables.ndjson'),
path.join(__dirname, '../../testdata/src/unknown-parameter-type.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/attachments.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/empty.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/global-hooks.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/global-hooks-attachments.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/hooks.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/minimal.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/rules.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/examples-tables.ndjson'),
path.join(import.meta.dirname, '../../testdata/src/unknown-parameter-type.ndjson'),
]
const queries: Queries = {
countMostSevereTestStepResultStatus: (query: Query) =>
Expand Down Expand Up @@ -316,7 +316,10 @@ describe('Acceptance Tests', async () => {

const expectedResults = JSON.parse(
fs.readFileSync(
path.join(__dirname, `../../testdata/src/${suiteName}.${methodName}.results.json`),
path.join(
import.meta.dirname,
`../../testdata/src/${suiteName}.${methodName}.results.json`
),
{
encoding: 'utf-8',
}
Expand Down
4 changes: 2 additions & 2 deletions javascript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Query from './Query'
import Query from './Query.js'

export * from './Lineage'
export * from './Lineage.js'

export { Query }
Loading