Closed abodnar closed 1 year ago
Hey @abodnar Thank you for using the library. That's weird. Can you please provide more details(os, typescript, playwright, odotta versions) on it? It would be fantastic if you could add a working example.
OS: macOS Ventura 13.4 Typescript: I think it's 4.8.4(shows bundled in Phpstorm as I'm not currently requiring one in the package.json) and if I do install typescript directly, it is 5.1.3 and nothing changes. Playwright: 1.32.2 Odotta: 1.1.15
This is what my config file looks like:
import { defineConfig, devices, expect } from '@playwright/test';
import playwrightApiMatchers from 'odottaa';
expect.extend(playwrightApiMatchers);
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
import 'dotenv/config'
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/thundercat-api',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
["list"],
["html", {
open: "never"
}]
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.API_BASEURL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chromium'] },
},
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
});
Sorry, for the late reply. But, I can't reproduce the issue on my side. In fact, the module has default export...Perhaps, you need to clean the npm cache or uninstall and install again the library.
Appreciate you looking into it. The more I've played with Playwright, the more I'm not sure it is the right tool for API testing.
Hi @elaichenkov
I was able to reproduce this issue. The solution that helps for me was to set esModuleInterop: true
in the TypeScript configuration (tsconfig.json)
{
"compilerOptions": {
"esModuleInterop": true,
// Other options...
}
}
Is it correct?
Recently working with Playwright and saw that odottaa adds some helpful assertions. So I decided I'd give it a try and see if I liked it.
After installing and following the instructions to add it to my playwright.config.ts.
My IDE Is warning me about this.
TS1192: Module '"/node_modules/odottaa/lib/src/index"' has no default export.
Doesn't seem to cause an issue, but would be nice if this didn't show as an issue on that file.