Skip to content

Commit aa836a7

Browse files
Copilotkobenguyent
andcommitted
Convert more CJS to ESM: AI and GraphQL helpers
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 1f6991d commit aa836a7

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

lib/helper/AI.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const HelperModule = require('@codeceptjs/helper')
2-
const ora = require('ora-classic')
3-
const fs = require('fs')
4-
const path = require('path')
5-
const ai = require('../ai')
6-
const Container = require('../container')
7-
const { splitByChunks, minifyHtml } = require('../html')
8-
const { beautify } = require('../utils')
9-
const output = require('../output')
10-
const { registerVariable } = require('../pause')
1+
import HelperModule from '@codeceptjs/helper'
2+
import ora from 'ora-classic'
3+
import fs from 'fs'
4+
import path from 'path'
5+
import ai from '../ai.js'
6+
import Container from '../container.js'
7+
import { splitByChunks, minifyHtml } from '../html.js'
8+
import { beautify } from '../utils.js'
9+
import output from '../output.js'
10+
import { registerVariable } from '../pause.js'
1111

1212
const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
1313

@@ -29,7 +29,7 @@ const gtpRole = {
2929
*
3030
* * `chunkSize`: (optional, default: 80000) - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
3131
*/
32-
class AI extends Helper {
32+
class AI extends HelperModule {
3333
constructor(config) {
3434
super(config)
3535
this.aiAssistant = ai
@@ -211,4 +211,4 @@ class AI extends Helper {
211211
}
212212
}
213213

214-
module.exports = AI
214+
export default AI

lib/helper/GraphQL.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const axios = require('axios').default
2-
const HelperModule = require('@codeceptjs/helper')
1+
import axios from 'axios'
2+
import HelperModule from '@codeceptjs/helper'
33

44
/**
55
* GraphQL helper allows to send additional requests to a GraphQl endpoint during acceptance tests.
@@ -36,7 +36,7 @@ const HelperModule = require('@codeceptjs/helper')
3636
*
3737
* ## Methods
3838
*/
39-
class GraphQL extends Helper {
39+
class GraphQL extends HelperModule {
4040
constructor(config) {
4141
super(config)
4242
this.axios = axios.create()
@@ -227,4 +227,4 @@ class GraphQL extends Helper {
227227
this.haveRequestHeaders({ Authorization: `Bearer ${accessToken}` })
228228
}
229229
}
230-
module.exports = GraphQL
230+
export default GraphQL

0 commit comments

Comments
 (0)