Skip to content

Commit

Permalink
feat(it-tests): test schematics with yarn 1
Browse files Browse the repository at this point in the history
  • Loading branch information
vscaiceanu-1a committed Jan 22, 2024
1 parent 0536b3c commit 7a0e5ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/it-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
packageManager: [yarn, npm]
packageManager: [yarn, npm, yarn1]
exclude:
- os: windows-latest
packageManager: yarn
Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/core/schematics/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('new otter application', () => {
execAppOptions
);

expect(() => packageManagerRun('build', execAppOptions)).not.toThrow();
expect(() => packageManagerRun('build', { ...execAppOptions, cwd: appFolderPath })).not.toThrow();

// should pass the e2e tests
packageManagerExec(`ng g @o3r/testing:playwright-scenario --name=test-scenario ${projectName}`, execAppOptions);
Expand Down
4 changes: 2 additions & 2 deletions packages/@o3r/test-helpers/src/prepare-test-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { minVersion } from 'semver';
import { createTestEnvironmentAngular } from './test-environments/create-test-environment-angular';
import { createTestEnvironmentAngularWithO3rCore } from './test-environments/create-test-environment-angular-with-o3r-core';
import { createTestEnvironmentBlank } from './test-environments/create-test-environment-blank';
import {createWithLock, packageManagerInstall, setPackagerManagerConfig} from './utilities';
import {createWithLock, isYarn1, packageManagerInstall, setPackagerManagerConfig, YARN_1_LATEST_VERSION} from './utilities';

/**
* 'blank' only create yarn/npm config
Expand Down Expand Up @@ -44,7 +44,7 @@ export async function prepareTestEnv(folderName: string, type: PrepareTestEnvTyp

const o3rCorePackageJson: PackageJson & { generatorDependencies?: Record<string, string> } =
JSON.parse(readFileSync(path.join(rootFolderPath, 'packages', '@o3r', 'core', 'package.json')).toString());
const yarnVersion: string = yarnVersionParam || getYarnVersionFromRoot(rootFolderPath);
const yarnVersion: string = yarnVersionParam || (isYarn1() && YARN_1_LATEST_VERSION) || getYarnVersionFromRoot(rootFolderPath);
const angularVersion = minVersion(o3rCorePackageJson.devDependencies?.['@angular-devkit/schematics'] || 'latest')?.version;
const materialVersion = minVersion(o3rCorePackageJson.generatorDependencies?.['@angular/material'] || angularVersion || 'latest')?.version;
const generateMonorepo = type === 'angular-monorepo' || type === 'angular-monorepo-with-o3r-core';
Expand Down
9 changes: 9 additions & 0 deletions packages/@o3r/test-helpers/src/utilities/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export function getPackageManager() {
'yarn';
}

export const YARN_1_LATEST_VERSION = '1.22.19';

/**
*
*/
export function isYarn1() {
return process.env.ENFORCED_PACKAGE_MANAGER === 'yarn1';
}

/**
* Need to add additional dashes when running command like exec on npm
* Convert `npm exec test --param` to `npm exec test -- --param`
Expand Down

0 comments on commit 7a0e5ad

Please sign in to comment.