Skip to content

Commit

Permalink
test playwright parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bjesus committed Sep 21, 2024
1 parent 73cf378 commit 0ae9f37
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions parsers/playwright_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package parsers

import (
"fmt"
"testing"

"github.com/bjesus/pipet/common"
"github.com/stretchr/testify/assert"
)

func TestExecutePlaywrightBlock(t *testing.T) {

block := common.Block{
Type: "playwright",
Command: "playwright http://example.com",
Queries: []string{"document.querySelector(\"h1\").innerText.split(\" \")", "document.querySelector(\"h1\") | wc -c"},
}
result, err := ExecutePlaywrightBlock(block)
expected := []interface{}{[]interface{}{"Example", "Domain"}, "11\n"}
fmt.Printf("%v", result)
assert.NoError(t, err)
assert.NotNil(t, result)
assert.Equal(t, expected, result) // Mocked JSON output

}

0 comments on commit 0ae9f37

Please sign in to comment.