Skip to content

Commit 3ff7798

Browse files
committed
Add quick ESM smoke test
Ensures ECMAScript import works
1 parent b937fb9 commit 3ff7798

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

.github/workflows/nodejs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ jobs:
5757
run: |
5858
npm run test:unit
5959
60+
- name: ECMAScript module test
61+
run: |
62+
npm run test:esm
63+
6064
license:
6165
name: License check
6266
runs-on: ubuntu-latest
@@ -110,3 +114,7 @@ jobs:
110114
- name: Unit test
111115
run: |
112116
bun run test:unit-bun
117+
118+
- name: ECMAScript module test
119+
run: |
120+
bun run test:esm

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test": "npm run build && npm run lint && tap",
1414
"test:unit": "npm run build && tap",
1515
"test:unit-bun": "bun run build && bunx tap",
16+
"test:esm": "npm run build && cd test/esm/ && npm install && node test-import.mjs",
1617
"test:coverage-100": "npm run build && tap --coverage --100",
1718
"test:coverage-report": "npm run build && tap --coverage && nyc report --reporter=text-lcov > coverage.lcov",
1819
"test:coverage-ui": "npm run build && tap --coverage --coverage-report=html",

test/esm/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "esm",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"@elastic/elasticsearch": "file:../.."
6+
}
7+
}

test/esm/test-import.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { Client } from '@elastic/elasticsearch'
21+
22+
new Client({
23+
node: 'http://localhost:9200',
24+
auth: {
25+
username: 'elastic',
26+
password: 'changeme',
27+
}
28+
})

0 commit comments

Comments
 (0)