Skip to content

Commit

Permalink
revert subpath imports to relative paths, #218
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Sep 10, 2024
1 parent a11c50d commit 370ecc4
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 46 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Dev
* revert `#` subpath imports to relative paths: consumers with `(module = commonjs) + (skipLibCheck = false)` can't compile the project ([#218](https://github.com/vitalets/playwright-bdd/issues/218))

## 7.3.0
* fix: skipped scenarios break cucumber reports ([#143](https://github.com/vitalets/playwright-bdd/issues/143))
* chore: update @cucumber/html-formatter ([#213](https://github.com/vitalets/playwright-bdd/issues/213))
Expand Down
8 changes: 0 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ export default [
// require is needed for some functions (copied from PW)
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-require-imports': 0,
'no-restricted-imports': [
'error',
{
// restrict high parent imports in favor of import subpaths (not path alias!)
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-imports-and-self-name-imports
patterns: ['../../../*'],
},
],
},
},
{
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
"./reporter/cucumber": "./dist/reporter/cucumber/index.js",
"./package.json": "./package.json"
},
"imports": {
"#*": {
"pw-bdd-dev": "./src/*",
"default": "./dist/*"
}
},
"engines": {
"node": ">=18"
},
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from 'commander';
import { ConfigOption } from '../options';
import { Logger } from '../../utils/logger';
import { getPackageVersion } from '../../utils';
import { resolveConfigFile } from '#playwright/loadConfig.js';
import { resolveConfigFile } from '../../playwright/loadConfig.js';
import { relativeToCwd } from '../../utils/paths';

const logger = new Logger({ verbose: true });
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/cucumber/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import fs from 'node:fs';
import { Writable } from 'node:stream';
import { finished } from 'node:stream/promises';
import { EventEmitter } from 'node:events';
import EventDataCollector from '#cucumber/formatter/EventDataCollector.js';
import EventDataCollector from '../../cucumber/formatter/EventDataCollector.js';

export type InternalOptions = {
cwd: string;
Expand Down
6 changes: 3 additions & 3 deletions src/reporter/cucumber/messagesBuilder/AttachmentMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
* 2.4 remove found attachment from attachments array
*/
import * as pw from '@playwright/test/reporter';
import { AutofillMap } from '#utils/AutofillMap.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';
import { collectStepsWithCategory, getHooksRootPwStep } from './pwStepUtils';
import { PwAttachment } from '#playwright/types.js';
import { stripAnsiEscapes } from '#utils/stripAnsiEscapes.js';
import { PwAttachment } from '../../../playwright/types.js';
import { stripAnsiEscapes } from '../../../utils/stripAnsiEscapes.js';

export class AttachmentMapper {
private stepAttachments = new AutofillMap<pw.TestStep, PwAttachment[]>();
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/cucumber/messagesBuilder/GherkinDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Attaches extra fields (meta).
*/
import * as messages from '@cucumber/messages';
import { GherkinDocumentWithPickles } from '#features/load.js';
import { GherkinDocumentWithPickles } from '../../../features/load.js';
import { ConcreteEnvelope } from './types';
import { omit } from '#utils/index.js';
import { omit } from '../../../utils/index.js';
import { ProjectInfo, getFeatureUriWithProject } from './Projects';

type GherkinDocumentMeta = {
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/cucumber/messagesBuilder/GherkinDocumentClone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* pickle IDs and pickle steps IDs.
*/
import { randomUUID } from 'node:crypto';
import { GherkinDocumentWithPickles, PickleWithLocation } from '#features/load.js';
import { AutofillMap } from '#utils/AutofillMap.js';
import { GherkinDocumentWithPickles, PickleWithLocation } from '../../../features/load.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';

export class GherkinDocumentClone {
private oldNewIds = new AutofillMap<string, string>();
Expand Down
10 changes: 5 additions & 5 deletions src/reporter/cucumber/messagesBuilder/GherkinDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
*/
import path from 'node:path';
import * as messages from '@cucumber/messages';
import { AutofillMap } from '#utils/AutofillMap.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';
import { TestCaseRun } from './TestCaseRun';
import { FeaturesLoader, GherkinDocumentWithPickles } from '#features/load.js';
import { getPlaywrightConfigDir } from '#config/configDir.js';
import { FeaturesLoader, GherkinDocumentWithPickles } from '../../../features/load.js';
import { getPlaywrightConfigDir } from '../../../config/configDir.js';
import { ConcreteEnvelope } from './types';
import { GherkinDocumentClone } from './GherkinDocumentClone';
import { GherkinDocumentMessage } from './GherkinDocument';
import { ProjectInfo, getFeatureUriWithProject } from './Projects';
import { getEnvConfigs } from '#config/env.js';
import { LANG_EN } from '#config/lang.js';
import { getEnvConfigs } from '../../../config/env.js';
import { LANG_EN } from '../../../config/lang.js';

export class GherkinDocuments {
private featuresLoader = new FeaturesLoader();
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/cucumber/messagesBuilder/Hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { randomUUID } from 'node:crypto';
import * as pw from '@playwright/test/reporter';
import * as messages from '@cucumber/messages';
import { getPlaywrightConfigDir } from '#config/configDir.js';
import { getPlaywrightConfigDir } from '../../../config/configDir.js';
import path from 'node:path';

export type HookType = 'before' | 'after';
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/cucumber/messagesBuilder/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import os from 'node:os';
import * as messages from '@cucumber/messages';
import { getPackageVersion } from '#utils/index.js';
import { getPackageVersion } from '../../../utils/index.js';

export class Meta {
buildMessage() {
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/cucumber/messagesBuilder/Pickles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Builds Pickle messages.
*/
import * as messages from '@cucumber/messages';
import { omit } from '#utils/index.js';
import { AutofillMap } from '#utils/AutofillMap.js';
import { omit } from '../../../utils/index.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';
import { TestCase } from './TestCase';
import { ConcreteEnvelope } from './types';
import { getFeatureUriWithProject } from './Projects';
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/cucumber/messagesBuilder/Projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See: https://github.com/microsoft/playwright/issues/29841
*/
import * as pw from '@playwright/test/reporter';
import { AutofillMap } from '#utils/AutofillMap.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';

export type ProjectInfo = {
projectName?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/reporter/cucumber/messagesBuilder/TestCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import * as messages from '@cucumber/messages';
import { TestCaseRun } from './TestCaseRun';
import { Hook, HookType } from './Hook';
import { GherkinDocumentWithPickles, PickleWithLocation } from '#features/load.js';
import { stringifyLocation } from '#utils/index.js';
import { GherkinDocumentWithPickles, PickleWithLocation } from '../../../features/load.js';
import { stringifyLocation } from '../../../utils/index.js';
import { ProjectInfo } from './Projects';
import { BddData } from '#run/bddAnnotation/types.js';
import { BddData } from '../../../run/bddAnnotation/types.js';

type HookWithStep = {
hook: Hook;
Expand Down
8 changes: 4 additions & 4 deletions src/reporter/cucumber/messagesBuilder/TestCaseRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
*/
import * as pw from '@playwright/test/reporter';
import * as messages from '@cucumber/messages';
import { stringifyLocation } from '#utils/index.js';
import { stringifyLocation } from '../../../utils/index.js';
import { Hook, HookType } from './Hook';
import { TestCase } from './TestCase';
import { AutofillMap } from '#utils/AutofillMap.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';
import { TestStepRun, TestStepRunEnvelope } from './TestStepRun';
import { toCucumberTimestamp } from './timing';
import { collectStepsWithCategory, isUnknownDuration } from './pwStepUtils';
import { AttachmentMapper } from './AttachmentMapper';
import { TestCaseRunHooks } from './TestCaseRunHooks';
import { ProjectInfo, getProjectInfo } from './Projects';
import { BddData, BddDataStep } from '#run/bddAnnotation/types.js';
import { getBddDataFromTest } from '#run/bddAnnotation/index.js';
import { BddData, BddDataStep } from '../../../run/bddAnnotation/types.js';
import { getBddDataFromTest } from '../../../run/bddAnnotation/index.js';

export type TestCaseRunEnvelope = TestStepRunEnvelope &
Pick<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'node:fs';
import * as pw from '@playwright/test/reporter';
import * as messages from '@cucumber/messages';
import { TestCaseRun } from './TestCaseRun';
import { PwAttachment } from '#playwright/types.js';
import { PwAttachment } from '../../../playwright/types.js';
import path from 'node:path';

export class TestStepAttachments {
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/cucumber/messagesBuilder/TestStepRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
import * as pw from '@playwright/test/reporter';
import * as messages from '@cucumber/messages';
import { stripAnsiEscapes } from '#utils/stripAnsiEscapes.js';
import { stripAnsiEscapes } from '../../../utils/stripAnsiEscapes.js';
import { TestCaseRun } from './TestCaseRun';
import { toCucumberTimestamp } from './timing';
import { TestStepAttachments } from './TestStepAttachments';
Expand Down
6 changes: 3 additions & 3 deletions src/reporter/cucumber/messagesBuilder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { TestCase } from './TestCase';
import { Meta } from './Meta';
import { TimeMeasured, calcMinMaxByArray, toCucumberTimestamp } from './timing';
import EventEmitter from 'node:events';
import EventDataCollector from '#cucumber/formatter/EventDataCollector.js';
import EventDataCollector from '../../../cucumber/formatter/EventDataCollector.js';
import { Hook } from './Hook';
import { AutofillMap } from '#utils/AutofillMap.js';
import { AutofillMap } from '../../../utils/AutofillMap.js';
import { GherkinDocuments } from './GherkinDocuments';
import { Pickles } from './Pickles';
import { ConcreteEnvelope } from './types';
import { hasBddConfig } from '#config/env.js';
import { hasBddConfig } from '../../../config/env.js';

export class MessagesBuilder {
private report = {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"useUnknownInCatchVariables": false,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"customConditions": ["pw-bdd-dev"],
"noEmit": true,
"resolveJsonModule": true,
"jsx": "react-jsx"
Expand Down

0 comments on commit 370ecc4

Please sign in to comment.