webdriverio / codemod

A codemod to transform Protractor into WebdriverIO tests
MIT License
25 stars 12 forks source link

@wdio/codemod/protractor doesn't work with typescript files #64

Closed robertIsaac closed 2 years ago

robertIsaac commented 2 years ago

I have this very simple spec file

import { browser, logging } from 'protractor';
import { AppPage } from '../../e2e/src/app.po';

describe('workspace-project App', () => {
  let page: AppPage;

  beforeEach(() => {
    page = new AppPage();
  });

  it('should display welcome message', async () => {
    await page.navigateTo();
    expect(await page.getTitleText()).toEqual('teste2e app is running!');
  });

  afterEach(async () => {
    // Assert that there are no errors emitted from the browser
    const logs = await browser.manage().logs().get(logging.Type.BROWSER);
    expect(logs).not.toContain(jasmine.objectContaining({
      level: logging.Level.SEVERE,
    } as logging.Entry));
  });
});

which is the default of angular 12 cli

trying to migrate it to wdio using npx jscodeshift -t ./node_modules/@wdio/codemod/protractor ./test/specs/app.e2e-spec.ts like what was suggested in the Migrate Test File

but it throw this error

% npx jscodeshift -t ./node_modules/@wdio/codemod/protractor ./test/specs/app.e2e-spec.ts
Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
 ERR ./test/specs/app.e2e-spec.ts Transformation error (Missing semicolon. (5:10))
SyntaxError: Missing semicolon. (5:10)
    at instantiate (/Users/irobert/teste2e/node_modules/@babel/parser/src/parse-error/credentials.js:61:22)
    at toParseError (/Users/irobert/teste2e/node_modules/@babel/parser/src/parse-error.js:58:12)
    at Object.raise (/Users/irobert/teste2e/node_modules/@babel/parser/src/tokenizer/index.js:1736:19)
    at Object.semicolon (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/util.js:146:10)
    at Object.parseVarStatement (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/statement.js:904:10)
    at Object.parseStatementContent (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/statement.js:391:21)
    at Object.parseStatement (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/statement.js:329:17)
    at Object.parseBlockOrModuleBlockBody (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/statement.js:1082:25)
    at Object.parseBlockBody (/Users/irobert/teste2e/node_modules/@babel/parser/src/parser/statement.js:1058:10)
    at Object.parseBlockBody (/Users/irobert/teste2e/node_modules/@babel/parser/src/plugins/estree.js:153:13)
All done. 
Results: 
1 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.730seconds 
christian-bromann commented 2 years ago

Duplicate of #28