Skip to content

Commit 0601089

Browse files
committed
fix: failed UTs
1 parent 9860591 commit 0601089

File tree

14 files changed

+45
-68
lines changed

14 files changed

+45
-68
lines changed

docs/data.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ I.sendPostRequest('/update-status', {}, { http_x_requested_with: 'xmlhttprequest
9292
## GraphQL
9393

9494
[GraphQL helper](https://codecept.io/helpers/GraphQL/) allows sending GraphQL queries and mutations to application, over Http.
95-
<<<<<<< HEAD
9695
This is a tool to make shortcuts and create your data pragmatically via GraphQL endpoint. However, it doesn't provide tools for testing the endpoint, so it should be paired with WebDriver helper for browser testing.
97-
=======
98-
This is a tool to make shortcuts and create your data pragmatically via GraphQL endpoint. However, it doesn't provide tools for testing the endpoint, so it should be paired with WebDriver helpers for browser testing.
99-
>>>>>>> 3.x
10096

10197
Enable GraphQL helper in the config. It is recommended to set `endpoint`, the URL to which the requests go to. If you need some authorization you can optionally set default headers too.
10298

lib/ai.cjs renamed to lib/ai.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const debug = require('debug')('codeceptjs:ai');
2-
const output = require('./output.js');
3-
const event = require('./event');
4-
const { removeNonInteractiveElements, minifyHtml, splitByChunks } = require('./html');
1+
import debug from 'debug';
2+
import * as event from './event.js';
3+
import * as output from './output.js';
4+
import { removeNonInteractiveElements, minifyHtml, splitByChunks } from './html.js';
5+
6+
debug('codeceptjs:ai');
57

68
const defaultHtmlConfig = {
79
maxLength: 50000,
@@ -250,5 +252,4 @@ function parseCodeBlocks(response) {
250252
return modifiedSnippets.filter(snippet => !!snippet);
251253
}
252254

253-
module.exports = new AiAssistant();
254-
255+
export default new AiAssistant();

lib/command/run-workers.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
// For Node version >=10.5.0, have to use experimental flag
2-
<<<<<<< HEAD
32
import { tryOrDefault } from '../utils.js';
4-
=======
5-
const { tryOrDefault } = require('../utils');
6-
const output = require('../output');
7-
const store = require('../store');
8-
const event = require('../event');
9-
const Workers = require('../workers');
10-
>>>>>>> 4.x
11-
3+
import { store } from '../store.js';
124
import * as output from '../output.js';
135
import * as event from '../event.js';
146
import { Workers } from '../workers.js';

lib/command/run.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import importSync from 'import-sync';
22
import {
33
getConfig, printError, getTestRoot, createOutputDir,
4-
<<<<<<< HEAD
54
} from './utils.js';
65
import Config from '../config.js';
76
import Codecept from '../codecept.js';
8-
=======
9-
} = require('./utils');
10-
const Config = require('../config');
11-
const store = require('../store');
12-
const Codecept = require('../codecept');
13-
>>>>>>> 4.x
7+
import { store } from '../store.js';
148

159
export default async function (test, options) {
1610
// registering options globally to use in config

lib/container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as WorkerStorage from './workerStorage.js';
1515
import { store } from './store.js';
1616
import { actor } from './actor.js';
1717

18-
const ai = require('./ai.cjs');
18+
import ai from './ai.js';
1919

2020
let container = {
2121
helpers: {},

lib/heal.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
const debug = require('debug')('codeceptjs:heal');
2-
const colors = require('chalk');
3-
const Container = require('./container');
4-
const recorder = require('./recorder');
5-
const output = require('./output');
6-
const event = require('./event');
1+
import debug from 'debug';
2+
import colors from 'chalk';
3+
import Container from './container.js';
4+
import recorder from './recorder.js';
5+
import * as event from './event.js';
6+
import { output } from './output.js';
7+
8+
const logger = debug('myapp:server');
9+
10+
logger('codeceptjs:heal');
711

812
/**
913
* @class
@@ -57,7 +61,7 @@ class Heal {
5761
const suggestions = [];
5862
const recipes = matchRecipes(this.recipes, this.contextName);
5963

60-
debug('Recipes', recipes);
64+
logger('Recipes', recipes);
6165

6266
const currentOutputLevel = output.level();
6367
output.level(0);
@@ -96,20 +100,20 @@ class Heal {
96100
const suggestions = await this.getCodeSuggestions(failureContext);
97101

98102
if (suggestions.length === 0) {
99-
debug('No healing suggestions found');
103+
logger('No healing suggestions found');
100104
throw error;
101105
}
102106

103107
output.debug(`Received ${suggestions.length} suggestion${suggestions.length === 1 ? '' : 's'}`);
104108

105-
debug(suggestions);
109+
logger(suggestions);
106110

107111
for (const suggestion of suggestions) {
108112
for (const codeSnippet of suggestion.snippets) {
109113
try {
110-
debug('Executing', codeSnippet);
114+
logger('Executing', codeSnippet);
111115
recorder.catch((e) => {
112-
debug(e);
116+
logger(e);
113117
});
114118

115119
if (typeof codeSnippet === 'string') {
@@ -131,7 +135,7 @@ class Heal {
131135
// recorder.session.restore();
132136
return;
133137
} catch (err) {
134-
debug('Failed to execute code', err);
138+
logger('Failed to execute code', err);
135139
recorder.ignoreErr(err); // healing did not help
136140
recorder.catchWithoutStop(err);
137141
await recorder.promise(); // wait for all promises to resolve
@@ -149,7 +153,7 @@ class Heal {
149153

150154
const heal = new Heal();
151155

152-
module.exports = heal;
156+
export { heal };
153157

154158
function matchRecipes(recipes, contextName) {
155159
return Object.entries(recipes)

lib/helper/AI.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
<<<<<<< HEAD:lib/helper/OpenAI.js
21
import Helper from '@codeceptjs/helper';
3-
import AiAssistant from '../ai.cjs';
2+
import AiAssistant from '../ai.js';
43
import standardActingHelpers from '../plugin/standardActingHelpers.js';
54
import Container from '../container.js';
6-
import { splitByChunks, minifyHtml } from '../html';
7-
=======
8-
const Helper = require('@codeceptjs/helper');
9-
const ai = require('../ai.cjs');
10-
const standardActingHelpers = require('../plugin/standardActingHelpers');
11-
const Container = require('../container');
12-
const { splitByChunks, minifyHtml } = require('../html');
13-
>>>>>>> 4.x:lib/helper/AI.js
5+
import { splitByChunks, minifyHtml } from '../html.js';
146

157
/**
168
* AI Helper for CodeceptJS.
@@ -27,7 +19,7 @@ const { splitByChunks, minifyHtml } = require('../html');
2719
class AI extends Helper {
2820
constructor(config) {
2921
super(config);
30-
this.aiAssistant = ai;
22+
this.aiAssistant = AiAssistant;
3123

3224
this.options = {
3325
chunkSize: 80000,
@@ -129,8 +121,4 @@ class AI extends Helper {
129121
}
130122
}
131123

132-
<<<<<<< HEAD:lib/helper/OpenAI.js
133-
export default OpenAI;
134-
=======
135-
module.exports = AI;
136-
>>>>>>> 4.x:lib/helper/AI.js
124+
export default AI;

lib/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import * as container from './container.js';
1313
import * as locator from './locator.js';
1414
import * as event from './event.js';
1515
import * as store from './store.js';
16+
import * as heal from './heal.js';
17+
import * as ai from './ai.js';
1618
/**
1719
* Index file for loading CodeceptJS programmatically.
1820
*
@@ -54,7 +56,7 @@ export {
5456
store,
5557
/** @type {typeof CodeceptJS.Locator} */
5658
locator,
57-
heal: require('./heal.js'),
58-
ai: require('./ai.cjs'),
59-
Workers
59+
heal,
60+
ai,
61+
workers,
6062
};

lib/pause.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import debug from 'debug';
66
import container from './container.js';
77
import history from './history.js';
88
import { store } from './store.js';
9-
import AiAssistant from './ai.cjs';
9+
import AiAssistant from './ai.js';
1010
import recorder from './recorder.js';
1111
import * as event from './event.js';
1212
import * as output from './output.js';

lib/plugin/heal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import debug from 'debug';
22
import colors from 'chalk';
33
import Container from '../container.js';
4-
import AiAssistant from '../ai.cjs';
4+
import AiAssistant from '../ai.js';
55
import recorder from '../recorder.js';
66
import * as event from '../event.js';
77
import * as output from '../output.js';

0 commit comments

Comments
 (0)